示例#1
0
        public IActionResult HomeAddressEdit(HomeAddressViewModel model)
        {
            var    response = ResponseModelFactory.CreateInstance;
            string guid     = model.HomeAddressUuid;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            using (_dbContext)
            {
                var entity = _dbContext.HomeAddress.FirstOrDefault(x => x.HomeAddressUuid == Guid.Parse(guid));
                entity.Address     = model.Address;
                entity.Addresscode = model.Addresscode;
                entity.Village     = model.Village;
                entity.Town        = model.Town;
                entity.Door        = model.Door;
                entity.Unit        = model.Unit;
                entity.Resregion   = model.Resregion;
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("编辑", "成功:编辑:地址库信息一条数据", _dbContext);
                }
                response.SetSuccess("修改成功");
                return(Ok(response));
            }
        }
示例#2
0
        public IActionResult HomeAddressCreate(HomeAddressViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            using (_dbContext)
            {
                var entity = new HaikanSmartTownCockpit.Api.Entities.HomeAddress();
                entity.HomeAddressUuid = Guid.NewGuid();
                entity.Address         = model.Address;
                entity.Addresscode     = model.Addresscode;
                entity.Village         = model.Village;
                entity.Town            = model.Town;
                entity.Door            = model.Door;
                entity.Unit            = model.Unit;
                entity.Resregion       = model.Resregion;
                //entity.AddTime = DateTime.Now.ToString("yyyy-MM-dd");
                //entity.AddPeople = model.addPeople;
                entity.AddTime   = DateTime.Now.ToString("yyyy-MM-dd");
                entity.AddPeople = AuthContextService.CurrentUser.DisplayName;
                entity.IsDeleted = 0;
                _dbContext.HomeAddress.Add(entity);
                int res = _dbContext.SaveChanges();
                if (res > 0)
                {
                    ToLog.AddLog("添加", "成功:添加:地址库信息一条数据", _dbContext);
                }
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }