public virtual async Task <JsonResult> Update(int id)
        {
            var chk = await _OrderSrv.CheckOwner(User.GetUserId(), id);

            if (!chk)
            {
                return(Json(new Modal {
                    IsSuccessful = false, Message = Strings.RecordNotFound
                }));
            }
            var findRep = await _OrderSrv.FindAsync(id);

            if (!findRep.IsSuccessful)
            {
                return(Json(new { IsSuccessful = false, Message = Strings.RecordNotFound.Fill(DomainString.Order) }));
            }
            return(Json(new Modal
            {
                Title = $"{Strings.Update} {DomainString.Order}",
                AutoSubmitBtnText = Strings.Edit,
                Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", findRep.Result),
                AutoSubmitUrl = Url.Action("Update", "StoreOrder"),
                ResetForm = false
            }));
        }
示例#2
0
        public virtual async Task <JsonResult> Update(int id)
        {
            var findRep = await _relativeSrv.FindWithAttachmentsAsync(id);

            if (!findRep.IsSuccessful)
            {
                return(Json(new { IsSuccessful = false, Message = Strings.RecordNotFound.Fill(DomainString.Relatives) }));
            }
            if (findRep.Result.RelativeAttachments != null)
            {
                foreach (var item in findRep.Result.RelativeAttachments)
                {
                    item.Url = $"{_configuration["CustomSettings:MainAddress"]}{item.Url}";
                }
            }

            return(Json(new Modal
            {
                Title = $"{Strings.Update} {DomainString.Relatives}",
                AutoSubmitBtnText = Strings.Edit,
                Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", findRep.Result),
                AutoSubmit = false,
                ResetForm = false
            }));
        }
 public virtual JsonResult Add()
 => Json(new Modal
 {
     Title      = $"{Strings.Add} {DomainString.Relatives}",
     Body       = ControllerExtension.RenderViewToString(this, "Partials/_Entity", new Relative()),
     AutoSubmit = false,
 });
示例#4
0
        public virtual async Task <JsonResult> Add(UserInRole model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { IsSuccessful = false, Message = ModelState.GetModelError() }));
            }
            var addRep = await _userInRoleSrv.Add(model);

            if (!addRep.IsSuccessful)
            {
                return(Json(addRep));
            }
            var getRep = _userInRoleSrv.Get(model.UserId).ToList();

            getRep.ForEach((x) =>
            {
                x.Role.UserInRoles = null;
            });

            return(Json(new Response <string>
            {
                IsSuccessful = true,
                Result = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_List", getRep)
            }));
        }
        public ActionResult Edit(int id)
        {
            WorkcenterDTO workcenterDto = new WorkcenterDTO();

            try
            {
                Workcenter workcenter = workcenterCrudService.Get(id);
                if (workcenter == null)
                {
                    logger.Error($"HttpNotFound! Url:{System.Web.HttpContext.Current.Request.UrlReferrer}");

                    //Dictionary<string, string> statys = new Dictionary<string, string>
                    //{
                    //    ["statys"] = "HttpNotFound"
                    //};

                    //return Json(statys, JsonRequestBehavior.AllowGet);
                    return(HttpNotFound());
                }
                else
                {
                    workcenterDto = AutoMapperWebUtil.WorkcenterEntitiesToDto(workcenter);
                }
            }
            catch (ValidationException ex)
            {
                ControllerExtension.ActionsOnException(logger, ex, ModelState);
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
            // workcenterViewModel.ModelState = this.ModelState;
            return(Json(workcenterDto, JsonRequestBehavior.AllowGet));
        }
示例#6
0
 public virtual JsonResult Add()
 => Json(new Modal
 {
     Title         = $"{Strings.Add} {DomainString.User}",
     Body          = ControllerExtension.RenderViewToString(this, "Partials/_Entity", new User()),
     AutoSubmitUrl = Url.Action("Add", "User")
 });
示例#7
0
        public virtual async Task <JsonResult> Update([FromServices] IAddressService addrSrv, int id)
        {
            var store = await _storeSrv.FindAsync(id);

            if (!store.IsSuccessful)
            {
                return(Json(new { IsSuccessful = false, Message = Strings.RecordNotFound }));
            }
            //var model = new StoreUpdateModel().CopyFrom(store.Result);
            if (store.Result.AddressId != null)
            {
                var addr = await addrSrv.FindAsync(store.Result.AddressId ?? 0);

                store.Result.Address = addr.IsSuccessful ? addr.Result : new Address();
            }
            else
            {
                store.Result.Address = new Address();
            }
            store.Result.ShopiaUrl = $"{_configuration["CustomSettings:ReactBaseUrl"]}/store/{id}";
            return(Json(new Modal
            {
                Title = $"{Strings.Update} {DomainString.Store}",
                AutoSubmitBtnText = Strings.Edit,
                Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", store.Result),
                AutoSubmit = false
            }));
        }
 public virtual JsonResult Add()
     => Json(new Modal
     {
         Title = $"{Strings.Add} {DomainString.Basket}",
         Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", new TempOrderDetail()),
         AutoSubmit = false
     });
示例#9
0
        public void RefLoopTest()
        {
            var obj = new RefLoop();

            obj.Loop = obj;

            var maskedResult = ControllerExtension.Mask(null, obj, "NoPatternName");
        }
示例#10
0
        public virtual async Task <JsonResult> RecoverPasswrod(string mobileNumber)
        {
            var emailModel = new EmailMessage();

            emailModel.Body = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_NewPassword", "");

            return(Json(await _userSrv.RecoverPassword(long.Parse(mobileNumber), _config["CustomSettings:EmailServiceConfig:EmailUserName"], emailModel)));
        }
        public ActionResult ValidateTeam(Team team)
        {
            try
            {
                //Check Access Rights
                if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName))
                {
                    return(PartialView("Error", "You Do Not Have Access to Teams. Please Contact an Administrator"));
                }

                //Validate Team data against Table
                if (!ModelState.IsValid)
                {
                    TeamTypeRepository teamTypeRepository = new TeamTypeRepository();
                    SelectList         teamTypesList      = new SelectList(teamTypeRepository.GetAllTeamTypes().ToList(), "TeamTypeCode", "TeamTypeDescription");
                    ViewData["TeamTypes"] = teamTypesList;

                    TablesDomainHierarchyLevelRepository tablesDomainHierarchyLevelRepository = new TablesDomainHierarchyLevelRepository();
                    SelectList hierarchyTypesList = new SelectList(tablesDomainHierarchyLevelRepository.GetDomainHierarchies(groupName).ToList(), "HierarchyLevelTableName", "HierarchyLevelTableName");
                    ViewData["HierarchyTypes"] = hierarchyTypesList;

                    return(Json(new WizardJSONResponse
                    {
                        html = ControllerExtension.RenderPartialViewToString(this, "TeamDetailsScreen", team),
                        message = "ValidationError",
                        success = false
                    }));
                }

                TeamSystemUsersVM teamUsersScreen = new TeamSystemUsersVM();
                teamUsersScreen.Team = team;
                if (team.TeamId > 0)
                {
                    teamUsersScreen.SystemUsers = teamWizardRepository.GetTeamSystemUsers(team.TeamId);
                }
                else
                {
                    // for Team with no Systemusers
                    List <spDDAWizard_SelectTeamSystemUsers_v1Result> systemUsers = new List <spDDAWizard_SelectTeamSystemUsers_v1Result>();
                    teamUsersScreen.SystemUsers = systemUsers;
                }
                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "TeamUsersScreen", teamUsersScreen),
                    message = "Success",
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "Error", ex.Message),
                    message = "UnhandledError",
                    success = false
                }));
            }
        }
示例#12
0
 public virtual JsonResult Add()
 => Json(new Modal
 {
     Title = $"{Strings.Add} {DomainString.Role}",
     Body  = ControllerExtension.RenderViewToString(this, "Partials/_Entity", new Role {
         Enabled = true
     }),
     AutoSubmitUrl = Url.Action("Add", "Role")
 });
示例#13
0
        public void ByPatternName()
        {
            var maskedResult = ControllerExtension.Mask(null, Category_PatternName.GetCategories(), "MaskName");

            foreach (var category in maskedResult)
            {
                Assert.Null(category.Children);
            }
        }
示例#14
0
 public virtual async Task <JsonResult> GetViaRole(int roleId)
 => Json(new Modal
 {
     IsSuccessful  = true,
     Title         = $"{DomainString.Action}",
     Body          = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_ListViaRole", _actionInRoleSrv.GetViaRole(roleId)),
     AutoSubmitUrl = Url.Action("Add", "Action"),
     AutoSubmit    = false
 });
示例#15
0
        public void ByPackageType()
        {
            var maskedResult = ControllerExtension.Mask(null, Category_PackageType.GetCategories());

            foreach (var category in maskedResult)
            {
                Assert.Null(category.Children);
            }
        }
        public ActionResult ValidateSystemUser(SystemUserWizardVM systemUserWizardViewModel)
        {
            SystemUser systemUser = new SystemUser();

            systemUser = systemUserRepository.GetUserBySystemUserGuid(systemUserWizardViewModel.SystemUser.SystemUserGuid);
            systemUserWizardViewModel.SystemUser = systemUser;

            if (systemUserWizardViewModel.SystemUserLocation == null)
            {
                ModelState.Clear();
                ModelState.AddModelError("SystemUser.LocationName", "Location Required");

                //Validation Error
                string msg = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        msg += error.ErrorMessage;
                    }
                }

                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "SystemUserDetailsScreen", systemUserWizardViewModel),
                    message = "ValidationError: " + msg,
                    success = false
                }));
            }

            //Validate SystemUser data against Table
            if (!ModelState.IsValid)
            {
                //not needed
            }

            //SystemUser + List of SystemUser's Teams
            SystemUserTeamsVM systemUserTeamsViewModel = new SystemUserTeamsVM();

            //Add Systemuser
            systemUserTeamsViewModel.SystemUser = systemUser;

            //Add SystemUser's Teams
            SystemUserTeamRepository systemUserTeamRepository             = new SystemUserTeamRepository();
            List <spDDAWizard_SelectSystemUserTeams_v1Result> systemUsers = new List <spDDAWizard_SelectSystemUserTeams_v1Result>();

            systemUserTeamsViewModel.Teams = systemUserWizardRepository.GetSystemUserTeams(systemUser.SystemUserGuid);

            //Return Page with list of SystemUser's Teams
            return(Json(new WizardJSONResponse
            {
                html = ControllerExtension.RenderPartialViewToString(this, "SystemUserTeamsScreen", systemUserTeamsViewModel),
                message = "Success",
                success = true
            }));
        }
 public virtual JsonResult Add()
 {
     ViewBag.Types = GetTypes();
     return(Json(new Modal
     {
         Title = $"{Strings.Add} {DomainString.Loss}",
         Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", new Loss()),
         AutoSubmit = false
     }));
 }
示例#18
0
 public virtual async Task <JsonResult> Add(int id)
 => Json(new Modal
 {
     AutoSubmit = false,
     Title      = $"{Strings.Add} {DomainString.User}",
     Body       = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Entity", new UserInRole {
         RoleId = id
     }),
     AutoSubmitUrl = Url.Action("Add", "UserInRole"),
 });
        public ActionResult ConfirmChangesScreen(SystemUserWizardVM updatedSystemUser)
        {
            //Messages that will be displayed to User
            WizardMessages wizardMessages = new WizardMessages();

            //Model to Store Original Item for Comparison
            SystemUserWizardVM originalSystemUserWizardViewModel = new SystemUserWizardVM();

            //Location
            SystemUserLocationRepository systemUserLocationRepository = new SystemUserLocationRepository();
            SystemUserLocation           originalSystemUserLocation   = new SystemUserLocation();

            originalSystemUserLocation = systemUserLocationRepository.GetSystemUserLocation(updatedSystemUser.SystemUser.SystemUserGuid);
            if (originalSystemUserLocation != null)
            {
                originalSystemUserWizardViewModel.SystemUserLocation = originalSystemUserLocation;
            }

            //System User
            SystemUser originalSystemUser = new SystemUser();

            originalSystemUser = systemUserRepository.GetUserBySystemUserGuid(updatedSystemUser.SystemUser.SystemUserGuid);
            if (originalSystemUser != null)
            {
                originalSystemUserWizardViewModel.SystemUser = originalSystemUser;
            }

            //GDSs
            SystemUserGDSRepository systemUserGDSRepository = new SystemUserGDSRepository();
            List <fnDesktopDataAdmin_SelectSystemUserGDSs_v1Result> originalSystemuserGDSs = new List <fnDesktopDataAdmin_SelectSystemUserGDSs_v1Result>();

            originalSystemuserGDSs = systemUserGDSRepository.GetSystemUserGDSs(updatedSystemUser.SystemUser.SystemUserGuid).ToList();
            if (originalSystemuserGDSs != null)
            {
                originalSystemUserWizardViewModel.SystemUserGDSs = originalSystemuserGDSs;
            }

            //ExternalSystemLoginSystemUserCountries
            ExternalSystemLoginRepository externalSystemLoginRepository = new ExternalSystemLoginRepository();
            List <ExternalSystemLoginSystemUserCountry> originalExternalSystemLoginSystemUserCountries = externalSystemLoginRepository.GetBackOfficeIdentifiers(updatedSystemUser.SystemUser.SystemUserGuid);

            if (originalExternalSystemLoginSystemUserCountries != null && originalExternalSystemLoginSystemUserCountries.Count > 0)
            {
                originalSystemUserWizardViewModel.ExternalSystemLoginSystemUserCountries = originalExternalSystemLoginSystemUserCountries;
            }

            systemUserWizardRepository.BuildSystemUserChangeMessages(wizardMessages, originalSystemUserWizardViewModel, updatedSystemUser);

            return(Json(new WizardJSONResponse
            {
                html = ControllerExtension.RenderPartialViewToString(this, "ConfirmChangesScreen", wizardMessages),
                message = "Success",
                success = true
            }));
        }
示例#20
0
        public void EFTest()
        {
            var options = new DbContextOptionsBuilder <TestContext>()
                          .UseInMemoryDatabase(databaseName: "Find_searches_url")
                          .Options;

            using (var context = new TestContext(options)) {
                Category_EF category_EF1;
                context.Categories.Add(category_EF1 = new Category_EF {
                    Name = "A"
                });

                category_EF1.Children.Add(new Category_EF()
                {
                    Name = "A-1"
                });

                context.Categories.Add(new Category_EF {
                    Name = "B"
                });
                context.Categories.Add(new Category_EF {
                    Name = "C"
                });
                context.SaveChanges();
            }

            using (var context = new TestContext(options)) {
                var data = ControllerExtension.Mask(
                    null,
                    context.Categories.Where(x => 1 == 1),
                    "Mask");

                foreach (var category in data)
                {
                    Assert.NotNull(category.Name);
                    Assert.Null(category.Children);
                    Assert.Null(category.Parent);
                }

                //嘗試儲存變更,確認是否deepclone有作用
                context.SaveChanges();
            }

            using (var context = new TestContext(options)) {
                Assert.True(context.Categories.Any(x => x.Children.Count > 0));
            }


            var data2 = new MyPaging <User>(User.GetList(), 0, 10);

            foreach (var item in data2.Result)
            {
                Assert.Null(item.Password);
            }
        }
 public virtual JsonResult Details(Guid id)
 {
     ViewBag.BasketUrl = $"{_configuration["CustomSettings:ReactTempBasketUrl"]}/{id}";
     return Json(new Modal
     {
         Title = $"{Strings.Details} {DomainString.Basket}",
         AutoSubmitBtnText = Strings.Edit,
         Body = ControllerExtension.RenderViewToString(this, "Partials/_Details", _TempOrderDetailSrv.GetDetails(id)),
         AutoSubmit = false
     });
 }
 public virtual async Task <JsonResult> Add()
 {
     ViewBag.Categories = GetCategories();
     return(Json(new Modal
     {
         IsSuccessful = true,
         Title = $"{Strings.Add} {DomainString.Product}",
         Body = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Entity", new Product()),
         AutoSubmit = false
     }));
 }
示例#23
0
        public virtual async Task <JsonResult> Update(Guid id)
        {
            var findUser = await _userSrv.FindAsync(id);

            if (!findUser.IsSuccessful)
            {
                return(Json(new Response <string> {
                    IsSuccessful = false, Message = Strings.RecordNotFound.Fill(DomainString.User)
                }));
            }

            var organization     = _configuration["CustomSettings:Organizations"].Split(";");
            var organizationList = new List <SelectListItem> {
                new SelectListItem {
                    Text = "", Value = "", Selected = true
                }
            };

            foreach (var item in organization)
            {
                organizationList.Add(new SelectListItem {
                    Text = item, Value = item, Selected = false
                });
            }

            var plans             = _configuration["InsurancePlanSettings:Plans"].Split(";");
            var insurancePlanList = new List <SelectListItem> {
                new SelectListItem {
                    Text = "", Value = "", Selected = true
                }
            };

            foreach (var item in plans)
            {
                insurancePlanList.Add(new SelectListItem {
                    Text = item, Value = item, Selected = false
                });
            }

            ViewBag.OrganizationList = organizationList;
            ViewBag.InsurancePlan    = insurancePlanList;


            return(Json(new Modal
            {
                Title = $"{Strings.Update} {DomainString.User}",
                AutoSubmitBtnText = Strings.Edit,
                Body = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Entity", findUser.Result),
                AutoSubmitUrl = Url.Action("Update", "User"),
                ResetForm = false
            }));
        }
示例#24
0
        public ActionResult ConfirmChangesScreen(LocationWizardVM updatedLocationViewModel)
        {
            //Make sure we have minimum data
            if (updatedLocationViewModel.Location == null)
            {
                return(Json(new WizardJSONResponse
                {
                    html = ControllerExtension.RenderPartialViewToString(this, "Error", "No Location Information"),
                    message = "Error",
                    success = false
                }));
            }

            //get LocationId
            int locationId = updatedLocationViewModel.Location.LocationId;

            //Object to store messages for Display
            WizardMessages wizardMessages = new WizardMessages();

            //Editing a Location
            if (locationId > 0)
            {
                //Get Original Information from Databse
                Location originalLocation = new Location();
                originalLocation = locationRepository.GetLocation(locationId);

                AddressRepository addressRepository = new AddressRepository();
                Address           originalAddress   = new Address();
                int addressId = updatedLocationViewModel.Address.AddressId;
                originalAddress = addressRepository.GetAddress(addressId);

                LocationWizardVM originalLocationViewModel = new LocationWizardVM();
                originalLocationViewModel.Location = originalLocation;
                originalLocationViewModel.Address  = originalAddress;

                //Compare Original Information to Submitted Information to Create a List of Messages about changes
                locationWizardRepository.BuildLocationChangeMessages(wizardMessages, originalLocationViewModel, updatedLocationViewModel);
            }
            else
            {
                //Adding an Item - Create a List of Messages about changes
                locationWizardRepository.BuildLocationChangeMessages(wizardMessages, null, updatedLocationViewModel);
            }

            //Return List of Changes to user for Final Confirmation
            return(Json(new WizardJSONResponse
            {
                html = ControllerExtension.RenderPartialViewToString(this, "ConfirmChangesScreen", wizardMessages),
                message = "Success",
                success = true
            }));
        }
示例#25
0
 public virtual async Task <JsonResult> Add()
 {
     ViewBag.Actions = GetActions();
     return(Json(new Modal
     {
         IsSuccessful = true,
         Title = $"{Strings.Add} {DomainString.Action}",
         Body = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Entity", new Action()),
         AutoSubmitUrl = Url.Action("Add", "Action"),
         AutoSubmit = false,
         ResetForm = true
     }));
 }
 public virtual async Task<JsonResult> Add([FromBody]IList<TempOrderDetail> items)
 {
     if (items == null || items.Count == 0) return Json(new { IsSuccessful = false, Message = Strings.ThereIsNoRecord });
     if (!ModelState.IsValid) return Json(new { IsSuccessful = false, Message = ModelState.GetModelError() });
     var add = await _TempOrderDetailSrv.AddRangeAsync(items);
     if (!add.IsSuccessful) return Json(add);
     var url = $"{_configuration["CustomSettings:ReactTempBasketUrl"]}/{add.Result}";
     return Json(new Response<string>
     {
         IsSuccessful = true,
         Result = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Result", new TempOrderDetailResultModel { Url = url })
     });
 }
示例#27
0
        public virtual async Task <JsonResult> Delete(int id)
        {
            var delete = await _productCatSrv.DeleteAsync(id);

            if (!delete.IsSuccessful)
            {
                return(Json(delete));
            }
            return(Json(new
            {
                IsSuccessful = true,
                Result = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_List", _productCatSrv.GetAll(new ProductCategorySearchFilter()))
            }));
        }
示例#28
0
        public virtual async Task <JsonResult> Update(int id)
        {
            var findProduct = await _productCatSrv.FindAsync(id);

            if (!findProduct.IsSuccessful)
            {
                return(Json(new Response <string> {
                    IsSuccessful = false, Message = Strings.RecordNotFound.Fill(DomainString.Product)
                }));
            }
            return(Json(new Response <string>
            {
                IsSuccessful = true,
                Result = await ControllerExtension.RenderViewToStringAsync(this, "Partials/_Entity", findProduct.Result)
            }));
        }
        public virtual async Task <JsonResult> Update(int id)
        {
            var findRep = await _productSerive.FindAsync(id);

            if (!findRep.IsSuccessful)
            {
                return(Json(new { IsSuccessful = false, Message = Strings.NotFound }));
            }
            ViewBag.Categories = GetCategories();
            return(Json(new Modal
            {
                Title = $"{Strings.Update} {DomainString.Product}",
                AutoSubmitBtnText = Strings.Edit,
                Body = ControllerExtension.RenderViewToString(this, "Partials/_Entity", findRep.Result),
                AutoSubmit = false
            }));
        }
示例#30
0
        public virtual async Task <JsonResult> Details(int id)
        {
            var findRep = await _OrderSrv.GetDetails(id);

            if (!findRep.IsSuccessful)
            {
                return(Json(new { IsSuccessful = false, Message = Strings.RecordNotFound.Fill(DomainString.Order) }));
            }

            return(Json(new Modal
            {
                Title = $"{Strings.Details} {DomainString.Order}",
                AutoSubmitBtnText = Strings.Edit,
                Body = ControllerExtension.RenderViewToString(this, "Partials/_Details", findRep.Result),
                AutoSubmit = false
            }));
        }