public ResponseObject <ServiceItemAPIViewModel> ViewDetail(int ServiceItemId) { try { var serviceItemRepo = DependencyUtils.Resolve <IServiceItemRepository>(); var serviceItem = serviceItemRepo.GetActive().SingleOrDefault(a => a.ServiceItemId == ServiceItemId); if (serviceItem != null) { var ServiceItemAPIViewModel = new ServiceItemAPIViewModel { ServiceName = serviceItem.ServiceITSupport.ServiceName, ServiceItemName = serviceItem.ServiceItemName, ServiceItemId = serviceItem.ServiceItemId, Description = serviceItem.Description, CreateDate = serviceItem.CreateDate.ToString("HH:mm dd/MM/yyyy"), UpdateDate = serviceItem.UpdateDate != null?serviceItem.UpdateDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty }; return(new ResponseObject <ServiceItemAPIViewModel> { IsError = false, ObjReturn = ServiceItemAPIViewModel, SuccessMessage = "Lấy chi tiết thành công" }); } return(new ResponseObject <ServiceItemAPIViewModel> { IsError = true, WarningMessage = "Không tồn tại dịch vụ này" }); } catch (Exception e) { return(new ResponseObject <ServiceItemAPIViewModel> { IsError = true, WarningMessage = "Không tồn tại dịch vụ này", ObjReturn = null, ErrorMessage = e.ToString() }); } }
public ResponseObject <bool> CreateTicket(List <AgencyCreateTicketAPIViewModel> listTicket, int RequestId) { try { var ticketRepo = DependencyUtils.Resolve <ITicketRepository>(); foreach (var item in listTicket) { var createTicket = new Ticket(); createTicket.RequestId = RequestId; createTicket.DeviceId = item.DeviceId; createTicket.Desciption = item.Desciption; createTicket.CreateDate = DateTime.UtcNow.AddHours(7); createTicket.CreateBy = item.CreateBy; ticketRepo.Add(createTicket); } ticketRepo.Save(); return(new ResponseObject <bool> { IsError = false, WarningMessage = "Tạo thành công!", ObjReturn = true }); } catch (Exception e) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Tạo thất bại!", ObjReturn = false, ErrorMessage = e.ToString() }); } }
public ResponseObject <List <ServiceITSupportAPIViewModel> > GetAllServiceITSupport() { List <ServiceITSupportAPIViewModel> rsList = new List <ServiceITSupportAPIViewModel>(); var serviceITSupportRepo = DependencyUtils.Resolve <IServiceITSupportRepository>(); var serviceITSupports = serviceITSupportRepo.GetActive().ToList(); if (serviceITSupports.Count <= 0) { return(new ResponseObject <List <ServiceITSupportAPIViewModel> > { IsError = true, WarningMessage = "Không có hợp đồng" }); } int count = 1; foreach (var item in serviceITSupports) { if (!item.IsDelete) { rsList.Add(new ServiceITSupportAPIViewModel { NumericalOrder = count, ServiceITSupportId = item.ServiceITSupportId, ServiceName = item.ServiceName, Description = item.Description, CreateDate = item.CreateDate.ToString("dd/MM/yyyy"), UpdateDate = item.UpdateDate.Value.ToString("dd/MM/yyyy") }); } count++; } return(new ResponseObject <List <ServiceITSupportAPIViewModel> > { IsError = false, ObjReturn = rsList, SuccessMessage = "Hiển thị hợp đồng thành công" }); }
public async Task <IdentityAccount> FindAsync(string userName, string password, int?churchId) { var service = DependencyUtils.Resolve <IIdentityAccountService>(); var user = await service.FindUsernameByChurch(userName, churchId); if (user == null) { return(null); } var hashResult = this.PasswordHasher.VerifyHashedPassword(user.PasswordHash, password); if (hashResult == PasswordVerificationResult.SuccessRehashNeeded) { await this.IdentityUserStore.SetPasswordHashAsync(user, this.PasswordHasher.HashPassword(password)); hashResult = PasswordVerificationResult.Success; } if (hashResult == PasswordVerificationResult.Success) { return(user); } else { return(null); } }
//ToanTXSE //Get screen List by location ID public static List <Models.ScreenVM> GetScreenIdByBrandId() { IScreenService screenService = DependencyUtils.Resolve <IScreenService>(); ILocationService locationService = DependencyUtils.Resolve <ILocationService>(); var ScreenVM = new List <Models.ScreenVM>(); var user = Helper.GetCurrentUser(); var screenList = screenService.GetScreenIdByBrandId(user.BrandID); foreach (var item in screenList) { var location = locationService.Get(item.LocationID); var locationString = location.Address + ", Quận " + location.District + ", TP." + location.Province; var m = new Models.ScreenVM { Name = item.ScreenName, Description = item.Description, ScreenId = item.ScreenID, isHorizontal = item.isHorizontal, LocationId = item.LocationID, Location = locationString, }; ScreenVM.Add(m); } return(ScreenVM); }
public static List <Models.ScheduleVM> GetSchedulesByBrandId() { IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>(); var scheduleVMs = new List <Models.ScheduleVM>(); IBrandService brandService = DependencyUtils.Resolve <IBrandService>(); var user = Helper.GetCurrentUser(); var scheduleList = deviceScenarioService.GetSchedulesByBrandID(user.BrandID); IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>(); foreach (var item in scheduleList) { var s = new Models.ScheduleVM { ScenarioID = item.ScenarioID, DeviceScenarioId = item.DeviceScenationID, DeviceID = item.DeviceID, DeviceName = deviceService.GetDeviceNameByID(item.DeviceID), ScenarioTitle = scenarioService.GetScenarioNameById(item.ScenarioID), StartTime = item.StartTime, TimeToPlay = item.TimesToPlay, EndTime = item.EndTime, }; scheduleVMs.Add(s); } return(scheduleVMs); }
public int CashBackPromotion(Membership mbs, double totalAmount) { IPromotionService promotionService = DependencyUtils.Resolve <IPromotionService>(); var promotionDetailService = DependencyUtils.Resolve <IPromotionDetailService>(); int point = 0; // get membershipType var mbsType = mbs.MembershipType; // code check promotion CashBack var code = mbsType.AppendCode + "_" + mbs.MembershipCode; // get promotionCashBack var promotion = promotionService.GetByPromoCode(ConstantManager.PROMOTION_CASH_BACK); if (promotion == null) { return(point); } // get list promotionDetail CashBack var promotionDetail = promotionDetailService.GetDetailByCode(promotion.PromotionCode).ToList(); foreach (var item in promotionDetail) { var check = Regex.IsMatch(code, item.RegExCode); if (check) { point = (int)(totalAmount / 10000 * item.PointTrade); return(point); } } return(point); }
//ToanTXSE //Get playlist List by location ID public static List <Models.PlaylistDetailVM> GetPlaylistIdByBrandIdAndStatus() { IPlaylistService playlistService = DependencyUtils.Resolve <IPlaylistService>(); IPlaylistItemService playlistItemService = DependencyUtils.Resolve <IPlaylistItemService>(); IBrandService brandService = DependencyUtils.Resolve <IBrandService>(); var mapper = DependencyUtils.Resolve <IMapper>(); var user = Helper.GetCurrentUser(); var playlistList = playlistService.GetPlaylistIdByBrandId(user.BrandID); var playlistDetailVM = new List <Models.PlaylistDetailVM>(); foreach (var item in playlistList) { if (item.isPublic == true) { var m = new Models.PlaylistDetailVM { Title = item.Title, Description = item.Description, Id = item.PlaylistID, isPublic = (bool)item.isPublic, Duration = playlistItemService.GetTotalDuration(item.PlaylistID), VisualTypeID = item.VisualTypeID ?? 1, }; playlistDetailVM.Add(m); } } //playlistDetailVM = playlistList.Select(mapper.Map<Playlist, Models.PlaylistDetailVM>).ToList(); return(playlistDetailVM); }
public ResponseObject <DeviceTypeAPIViewModel> ViewDetail(int devicetype_id) { var devicetypeRepo = DependencyUtils.Resolve <IDeviceTypeRepository>(); var devicetype = devicetypeRepo.GetActive().SingleOrDefault(a => a.DeviceTypeId == devicetype_id); if (devicetype != null) { var devicetypeAPIViewModel = new DeviceTypeAPIViewModel { DeviceTypeId = devicetype.DeviceTypeId, DeviceTypeName = devicetype.DeviceTypeName, ServiceId = devicetype.ServiceId, ServiceName = devicetype.ServiceITSupport.ServiceName, Description = devicetype.Description, CreateDate = devicetype.CreateDate.ToString("dd/MM/yyyy"), UpdateDate = devicetype.UpdateDate.Value.ToString("dd/MM/yyyy"), }; return(new ResponseObject <DeviceTypeAPIViewModel> { IsError = false, ObjReturn = devicetypeAPIViewModel, SuccessMessage = "Lấy chi tiết thành công" }); } return(new ResponseObject <DeviceTypeAPIViewModel> { IsError = true, WarningMessage = "Không tồn tại loại thiết bị này" }); }
public List <ProductBrandAPIViewModel> GetProductBrand(ProductBrandRequest <string> request) { var repo = DependencyUtils.Resolve <IProductBrandRepository>(); int index = (int)request.Page; int range = (index - 1) * (int)request.Limit; //var pro = repo.Get().AsEnumerable() // .Where(p => (request.Name == null ||p.Name.ToUpper().Contains(request.Name.ToUpper()))). // Select(p => new ProductBrandAPIViewModel(p)).ToList(); var pro = repo.Get() .Where(p => (request.Name == null || p.Name.ToUpper().Contains(request.Name.ToUpper()))); if (request.Ids != null) { var listId = request.Ids.Split(','); // filter Id pro = from p in pro where listId.Contains(p.ProductBrandId.ToString()) select p; } // OrderBy by Id of ProductBrand , page and limit pro = pro.OrderBy(p => p.ProductBrandId).Skip(range).Take(request.Limit.Value); var productBrandVM = pro.ToList().Select(p => new ProductBrandAPIViewModel(p)).ToList(); return(productBrandVM); }
// GET: Playlist/Detail/:id public ActionResult Detail(int id) { IPlaylistItemService playlistItemService = DependencyUtils.Resolve <IPlaylistItemService>(); IMediaSrcService mediaSrcService = DependencyUtils.Resolve <IMediaSrcService>(); var playlistItems = playlistItemService.GetMediaSrcByPlaylistId(id); var playlistItemVMs = new List <Models.PlaylistItemVM>(); if (playlistItems != null) { foreach (var item in playlistItems) { var p = new Models.PlaylistItemVM { playlistId = item.PlaylistID, mediaSrcId = item.MediaSrcID, displayOrder = item.DisplayOrder, duration = item.Duration, playlistItemId = item.PlaylistItemID, }; var mediaSrc = mediaSrcService.GetById(item.MediaSrcID); if (mediaSrc != null) { p.mediaSrcTitle = mediaSrc.Title; p.URL = mediaSrc.URL; p.mediaType = mediaSrc.TypeID; } playlistItemVMs.Add(p); } } ViewBag.playlistItemList = playlistItemVMs; return(View("Detail")); }
public ResponseObject <List <ServiceItemAPIViewModel> > GetAllServiceItemByServiceId(int serviceId) { List <ServiceItemAPIViewModel> rsList = new List <ServiceItemAPIViewModel>(); var serviceItemRepo = DependencyUtils.Resolve <IServiceItemRepository>(); var serviceItems = serviceItemRepo.GetActive(p => p.ServiceITSupportId == serviceId).ToList(); if (serviceItems.Count <= 0) { return(new ResponseObject <List <ServiceItemAPIViewModel> > { IsError = true, WarningMessage = "Không có dịch vụ nào hỗ trợ" }); } int count = 1; foreach (var item in serviceItems) { rsList.Add(new ServiceItemAPIViewModel { NumericalOrder = count, ServiceId = item.ServiceITSupportId, ServiceItemId = item.ServiceItemId, ServiceItemName = item.ServiceItemName, Description = item.Description != null ? item.Description : string.Empty, CreateDate = item.CreateDate.ToString("HH:mm dd/MM/yyyy"), UpdateDate = item.UpdateDate != null ? item.UpdateDate.Value.ToString("HH:mm dd/MM/yyyy") : string.Empty }); count++; } return(new ResponseObject <List <ServiceItemAPIViewModel> > { IsError = false, ObjReturn = rsList, SuccessMessage = "Hiển thị danh sách dịch vụ" }); }
public ResponseObject <bool> CreateServiceItem(ServiceItemAPIViewModel model) { try { var serviceItemRepo = DependencyUtils.Resolve <IServiceItemRepository>(); var serviceItem = new ServiceItem(); serviceItem.ServiceITSupportId = model.ServiceId; serviceItem.ServiceItemName = model.ServiceItemName; serviceItem.Description = model.Description; serviceItem.CreateDate = DateTime.UtcNow.AddHours(7); serviceItem.UpdateDate = DateTime.UtcNow.AddHours(7); serviceItemRepo.Add(serviceItem); serviceItemRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Tạo dịch vụ thành công!", ObjReturn = true }); } catch (Exception e) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Xóa dịch vụ thất bại!", ObjReturn = false, ErrorMessage = e.ToString() }); } }
public ResponseObject <bool> UpdateServiceItem(ServiceItemUpdateAPIViewModel model) { try { var serviceItemRepo = DependencyUtils.Resolve <IServiceItemRepository>(); var updateServiceItem = serviceItemRepo.GetActive().SingleOrDefault(a => a.ServiceItemId == model.ServiceItemId); if (updateServiceItem != null) { updateServiceItem.ServiceItemName = model.ServiceItemName; updateServiceItem.Description = model.Description; updateServiceItem.UpdateDate = DateTime.UtcNow.AddHours(7); serviceItemRepo.Edit(updateServiceItem); serviceItemRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Chỉnh sửa dịch vụ thành công", ObjReturn = true }); } return(new ResponseObject <bool> { IsError = true, WarningMessage = "Chỉnh sửa dịch vụ thất bại", ObjReturn = false }); } catch (Exception e) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Chỉnh sửa dịch vụ thất bại", ObjReturn = false, ErrorMessage = e.ToString() }); } }
public async System.Threading.Tasks.Task <ActionResult> Update(Models.ScheduleAddVM model) { IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>(); if (ModelState.IsValid && CheckTimeValid(model.DeviceID, model.StartTime, model.EndTime)) { if (model.isFixed) { model.TimeToPlay = null; } else { model.EndTime = null; } var schedule = deviceScenarioService.Get(model.DeviceScenarioId); if (schedule != null) { schedule.ScenarioID = model.ScenarioID; schedule.DeviceID = model.DeviceID; schedule.EndTime = model.EndTime; schedule.StartTime = model.StartTime; schedule.TimesToPlay = model.TimeToPlay; } await deviceScenarioService.UpdateAsync(schedule); return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Scheduling")), ContentType = "text/html" }); } return(View("Form", model)); }
public ResponseObject <bool> CreateDeviceType(DeviceTypeAPIViewModel model) { var devicetypeRepo = DependencyUtils.Resolve <IDeviceTypeRepository>(); var createDeviceType = new DeviceType(); try { createDeviceType.DeviceTypeId = model.DeviceTypeId; createDeviceType.ServiceId = model.ServiceId; createDeviceType.DeviceTypeName = model.DeviceTypeName; createDeviceType.Description = model.Description; createDeviceType.IsDelete = false; createDeviceType.CreateDate = DateTime.UtcNow.AddHours(7); createDeviceType.UpdateDate = DateTime.UtcNow.AddHours(7); devicetypeRepo.Add(createDeviceType); devicetypeRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Thêm loại thiết bị thành công", ObjReturn = true }); } catch (Exception ex) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Thêm loại thiết bị thất bại", ErrorMessage = ex.ToString(), ObjReturn = false }); } }
public async System.Threading.Tasks.Task <ActionResult> Add(Models.ScheduleAddVM model) { IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>(); if (ModelState.IsValid && CheckTimeValid(model.DeviceID, model.StartTime, model.EndTime)) { if (model.isFixed) { model.TimeToPlay = null; } else { model.EndTime = null; } IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>(); var schedule = new Data.Models.Entities.DeviceScenario { ScenarioID = model.ScenarioID, DeviceID = model.DeviceID, TimesToPlay = model.TimeToPlay, StartTime = model.StartTime, EndTime = model.EndTime, LayoutID = scenarioService.GetLayoutIDById(model.ScenarioID), }; await deviceScenarioService.CreateAsync(schedule); return(new ContentResult { Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Scheduling")), ContentType = "text/html" }); } return(View("Form", model)); }
// GET: Location/Form/:id public ActionResult Form(int?id) { DateTime aDateTime = DateTime.Now; Models.LocationDetailVM model = null; IBrandService brandService = DependencyUtils.Resolve <IBrandService>(); if (id != null) { var location = this.locationService.Get(id); if (location != null) { model = new Models.LocationDetailVM { BrandId = location.BrandID, LocationId = location.LocationID, BrandName = brandService.GetBrandNameByID(location.BrandID), Province = location.Province, District = location.District, Address = location.Address, Description = location.Description, Time = aDateTime }; } } ViewBag.brandList = BrandController.GetBrandList(); return(View(model)); }
// GET: Scheduling/Form/:id public ActionResult Form(int?id) { Models.ScheduleAddVM model = null; if (id != null) { IDeviceScenarioService deviceScenarioService = DependencyUtils.Resolve <IDeviceScenarioService>(); IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>(); var item = deviceScenarioService.Get(id); if (item != null) { model = new Models.ScheduleAddVM { ScenarioID = item.ScenarioID, DeviceScenarioId = item.DeviceScenationID, DeviceID = item.DeviceID, isHorizontal = scenarioService.GetScenarioOrientationById(item.ScenarioID) ?? true, isFixed = item.TimesToPlay == null, StartTime = item.StartTime, TimeToPlay = item.TimesToPlay, EndTime = item.EndTime, LayoutID = item.LayoutID, }; } } return(View(model)); }
public JsonResult ReceiveLocationId(string id) { int locationId = Int32.Parse(id); try { var locations = this.locationService.Get().ToList(); var locationVMs = new List <Models.LocationDetailVM>(); IMapper mapper = DependencyUtils.Resolve <IMapper>(); foreach (var item in locations) { if (item.LocationID == locationId) { var b = new Models.LocationDetailVM { LocationId = item.LocationID, BrandId = item.BrandID, Province = item.Province, District = item.District, Address = item.Address, Description = item.Description }; locationVMs.Add(b); } } return(Json(new { locationIdDelete = locationVMs, }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public async Task <IdentityAccount> FindAsync(string userName, int?churchId) { var service = DependencyUtils.Resolve <IIdentityAccountService>(); var user = await service.FindUsernameByChurch(userName, churchId); return(user); }
// GET: AdvancedScheduling public ActionResult Index() { IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>(); var ScheduleList = scheduleService.Get().ToList(); var ScheduleVMs = new List <DSS.Models.AdvancedScheduleVM>(); foreach (var item in ScheduleList) { var s = new DSS.Models.AdvancedScheduleVM { ScenarioID = item.ScenarioID, ScheduleID = item.ScheduleID, DeviceID = item.DeviceID, isEnable = item.isEnable, DeviceName = deviceService.GetDeviceNameByID(item.DeviceID), ScenarioTitle = scenarioService.GetScenarioNameById(item.ScenarioID), }; ScheduleVMs.Add(s); } ViewBag.ScheduleList = ScheduleVMs; ViewBag.addSuccess = Session["ADD_RESULT"] ?? false; ViewBag.updateSuccess = Session["UPDATE_RESULT"] ?? false; Session.Clear(); return(View()); }
public JsonResult CheckScreenIdIsMatching(int id) { try { //Get device by screen Id IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); var device = deviceService.Get(a => a.ScreenID == id).FirstOrDefault(); //bool isUsing = true; //if (device == null) //{ // isUsing = false; //} DSS.Models.MatchingDeviceVM deviceVM = null; if (device != null) { deviceVM = new DSS.Models.MatchingDeviceVM { Title = device.Title, }; } return(Json(new { isUsing = device != null, deviceVM = deviceVM, }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
// GET: Scheduling/Form/:id public ActionResult Form(int?id) { Models.AdvancedScheduleAddVM model = null; ViewBag.TimeSlotList = this.GetTimeSlots(); if (id != null) { IScheduleService scheduleService = DependencyUtils.Resolve <IScheduleService>(); IDeviceService deviceService = DependencyUtils.Resolve <IDeviceService>(); IScenarioService scenarioService = DependencyUtils.Resolve <IScenarioService>(); var item = scheduleService.Get(id); if (item != null) { model = new Models.AdvancedScheduleAddVM { ScenarioID = item.ScenarioID, ScheduleID = item.ScheduleID, DeviceID = item.DeviceID, isHorizontal = scenarioService.GetScenarioOrientationById(item.ScenarioID) ?? true, LayoutID = item.LayoutID, Priority = item.Priority, TimeFilterPoint = item.TimeFilter, DayFilterPoint = item.DayFilter, isEnable = item.isEnable, }; } } return(View(model)); }
public ResponseObject <bool> CreateAgency(AgencyAPIViewModel model) { try { var ticketTaskRepo = DependencyUtils.Resolve <IAgencyRepository>(); var createTask = new Agency(); createTask.CompanyId = model.CompanyId; createTask.AccountId = model.AccountId; createTask.AgencyName = model.AgencyName; createTask.Address = model.Address; createTask.Telephone = model.Telephone; createTask.IsDelete = false; createTask.CreateDate = DateTime.UtcNow.AddHours(7); ticketTaskRepo.Add(createTask); ticketTaskRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Tạo chi nhánh thành công!", ObjReturn = true }); } catch (Exception e) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Xóa chi nhánh thất bại!", ObjReturn = false, ErrorMessage = e.ToString() }); } }
public ResponseObject <bool> RemoveContract(int contract_id) { try { var contracttRepo = DependencyUtils.Resolve <IContractRepository>(); var contractServiceRepo = DependencyUtils.Resolve <IContractServiceITSupportRepository>(); var contract = contracttRepo.GetActive().SingleOrDefault(a => a.ContractId == contract_id); var contractServices = contractServiceRepo.GetActive().Where(a => a.ContractId == contract_id).ToList(); Deactivate(contract); foreach (var itemDB in contractServices) { itemDB.UpdateDate = DateTime.UtcNow.AddHours(7); contractServiceRepo.Deactivate(itemDB); } contractServiceRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Xóa hợp đồng thành công", ObjReturn = true }); } catch (Exception ex) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Xóa hợp đồng thất bại", ErrorMessage = ex.ToString(), ObjReturn = false }); } }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>(); var church = DependencyUtils.Resolve <IdentityChurch>(); if (church == null || church.ChurchDomain == null) { context.SetError("bad_request", "Invalid Hostname"); return; } var user = await userManager.FindAsync(context?.UserName, context?.Password, church.Church.Id); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, OAuthDefaults.AuthenticationType); ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType); AuthenticationProperties properties = CreateProperties(user.UserName); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket); context.Request.Context.Authentication.SignIn(cookiesIdentity); }
public ResponseObject <List <ContractAPIViewModel> > ViewAllContractServiceByContractId(int contract_id) { try { List <ContractAPIViewModel> rsList = new List <ContractAPIViewModel>(); var contractServiceRepo = DependencyUtils.Resolve <IContractServiceITSupportRepository>(); var servicesOfContract = contractServiceRepo.GetActive(p => p.ContractId == contract_id).ToList(); if (servicesOfContract.Count <= 0) { return(new ResponseObject <List <ContractAPIViewModel> > { IsError = true, WarningMessage = "Không tìm thấy hợp đòng nào!" }); } int count = 1; foreach (var item in servicesOfContract) { rsList.Add(new ContractAPIViewModel { NumericalOrder = count, ContractServiceName = item.ServiceITSupport.ServiceName, }); count++; } return(new ResponseObject <List <ContractAPIViewModel> > { IsError = false, ObjReturn = rsList, SuccessMessage = "Tìm thấy hợp đòng" }); } catch (Exception e) { return(new ResponseObject <List <ContractAPIViewModel> > { IsError = true, WarningMessage = "Không tìm thấy hợp đòng nào!", ObjReturn = null, ErrorMessage = e.ToString() }); } }
public ResponseObject <bool> CreateServiceITSupport(ServiceITSupportAPIViewModel model) { var serviceITSupportRepo = DependencyUtils.Resolve <IServiceITSupportRepository>(); var createServiceitsupport = new ServiceITSupport(); try { createServiceitsupport.ServiceITSupportId = model.ServiceITSupportId; createServiceitsupport.ServiceName = model.ServiceName; createServiceitsupport.Description = model.Description; createServiceitsupport.IsDelete = false; createServiceitsupport.CreateDate = DateTime.UtcNow.AddHours(7); createServiceitsupport.UpdateDate = DateTime.UtcNow.AddHours(7); serviceITSupportRepo.Add(createServiceitsupport); serviceITSupportRepo.Save(); return(new ResponseObject <bool> { IsError = false, SuccessMessage = "Thêm loại dịch vụ thành công", ObjReturn = true }); } catch (Exception ex) { return(new ResponseObject <bool> { IsError = true, WarningMessage = "Thêm loại dịch vụ thất bại", ErrorMessage = ex.ToString(), ObjReturn = false }); } }
public async Task <OrderAPIViewModel> GetOrder(int orderId) { var orderService = DependencyUtils.Resolve <IOrderService>(); var order = await orderService.GetOrder(orderId); return(order); }