2019-07-25 14:58:13 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Web.Mvc;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
using BeWo.View.Navigation.Filter;
|
|
|
|
|
|
using BeWoPlanerMobil.Service;
|
2020-04-16 15:57:01 +02:00
|
|
|
|
using BeWoPlanerMobil.Util;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
using BS.Shared;
|
2019-07-25 14:58:13 +02:00
|
|
|
|
using BS.Shared.DataContracts;
|
|
|
|
|
|
using BS.Shared.DataContracts.Compact;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BeWoPlanerMobil.Models
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CustomerModel : AbstractModel
|
|
|
|
|
|
{
|
|
|
|
|
|
[Display(Name = "Klient")]
|
|
|
|
|
|
public long? SelectedCustomerOid { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public CustomerDC SelectedCustomer { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public List<CompactCustomerDC> Customers { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<SelectListItem> CustomerListItems
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = new List<SelectListItem> { new SelectListItem { Value = "-1", Text = string.Empty } };
|
|
|
|
|
|
result.AddRange(Customers.Select(item => new SelectListItem { Value = item.CustomerOid.ToString(), Text = string.Format("{1}, {0}", item.FirstName, item.LastName) }).ToList());
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-04-16 15:57:01 +02:00
|
|
|
|
|
|
|
|
|
|
public JsonCustomer SelectedJsonCustomer => SelectedCustomer != null ? new JsonCustomer(SelectedCustomer) : null;
|
2021-04-19 04:38:29 +02:00
|
|
|
|
|
|
|
|
|
|
[Display(Name = "Filter")]
|
|
|
|
|
|
public CustomerFilterEnum SelectedCustomerFilter { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public List<SelectListItem> CustomerFilter
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = new List<SelectListItem>();
|
|
|
|
|
|
|
|
|
|
|
|
var user = MobileSessionFacade.LoggedInUser;
|
|
|
|
|
|
|
|
|
|
|
|
const string allCustomers = "Alle Klienten anzeigen";
|
|
|
|
|
|
const string myCustomersOnly = "Nur meine Klienten anzeigen";
|
|
|
|
|
|
const string myTeamsCustomersOnly = "Nur Klienten meiner Teams anzeigen";
|
|
|
|
|
|
|
|
|
|
|
|
const string allCustomersValue = "0";
|
|
|
|
|
|
const string myCustomersValue = "1";
|
|
|
|
|
|
const string myTeamsCustomersValue = "2";
|
|
|
|
|
|
|
|
|
|
|
|
if(user != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(user.CheckForRight(UserRightType.ViewAll))
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Add(new SelectListItem { Text = allCustomers, Value = allCustomersValue });
|
|
|
|
|
|
result.Add(new SelectListItem { Text = myCustomersOnly, Value = myCustomersValue });
|
|
|
|
|
|
|
|
|
|
|
|
if(user.CheckForRight(UserRightType.Customer_ViewMyTeams))
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Add(new SelectListItem {Text = myTeamsCustomersOnly, Value = myTeamsCustomersValue });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(user.CheckForRight(UserRightType.Customer_ViewMyTeams))
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Add(new SelectListItem { Text = myCustomersOnly, Value = myCustomersValue });
|
|
|
|
|
|
result.Add(new SelectListItem { Text = myTeamsCustomersOnly, Value = myTeamsCustomersValue });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-07-25 14:58:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|