Пример #1
0
        public async Task <IActionResult> PutMstCity([FromRoute] int id, [FromBody] MstCity mstCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mstCity.CityId)
            {
                return(BadRequest());
            }

            _context.Entry(mstCity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MstCityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public long RegisterCity(MstCity city)
        {
            long result = 0;

            //Check create new customer
            StringBuilder sqlinsert = new StringBuilder();

            city.DEL_FLG = DeleteFlag.NON_DELETE;

            sqlinsert.Append(@" 
                    INSERT INTO [MstCity] 
                        ([CITY_CD]
                        ,[CITY_ZIP_CD]
                        ,[CITY_NAME]
                        ,[DSP_ORDER]
                        ,[DEL_FLG]
                        ,[STATUS])
                    VALUES
                        (@CITY_CD,
                        @CITY_ZIP_CD,
                        @CITY_NAME,
                        @DSP_ORDER,
                        @DEL_FLG,
                        @STATUS)");

            result = base.DbAdd(sqlinsert.ToString(), city);
            return(result);
        }
Пример #3
0
        public ActionResult Edit(CityModel model)
        {
            try
            {
                using (ManageCityService service = new ManageCityService())
                {
                    if (ModelState.IsValid)
                    {
                        bool    isNew  = false;
                        MstCity entity = new MstCity();
                        //int ExistCity = da.MstCity.SingleOrDefault(i => i.CITY_CD == model.CITY_CD) == null? 0 : 1;
                        if (model.CITY_CD_HIDDEN == 0)
                        {
                            isNew              = true;
                            entity.DEL_FLG     = DeleteFlag.NON_DELETE;
                            entity.CITY_CD     = model.CITY_CD;
                            entity.CITY_ZIP_CD = model.CITY_ZIP_CD;
                            entity.CITY_NAME   = model.CITY_NAME;
                            entity.DSP_ORDER   = model.DSP_ORDER;
                            entity.STATUS      = model.STATUS;

                            service.InsertCity(entity);
                            JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet);
                            return(result);
                        }
                        else
                        {
                            isNew              = false;
                            entity.CITY_CD     = model.CITY_CD;
                            entity.DEL_FLG     = DeleteFlag.NON_DELETE;
                            entity.CITY_ZIP_CD = model.CITY_ZIP_CD;
                            entity.CITY_NAME   = model.CITY_NAME;
                            entity.DSP_ORDER   = model.DSP_ORDER;
                            entity.STATUS      = model.STATUS;

                            service.UpdateCity(entity);
                            JsonResult result = Json(new { isNew = isNew }, JsonRequestBehavior.AllowGet);
                            return(result);
                        }
                    }
                    else
                    {
                        var ErrorMessages = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray();
                    }

                    return(new EmptyResult());
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                System.Web.HttpContext.Current.Session["ERROR"] = ex;
                return(new EmptyResult());
            }
        }
Пример #4
0
        public async Task <IActionResult> PostMstCity([FromBody] MstCity mstCity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.MstCity.Add(mstCity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMstCity", new { id = mstCity.CityId }, mstCity));
        }
Пример #5
0
        public long UpdateCity(MstCity city)
        {
            var ManageCityDa = new ManageCityDa();

            long res = 0;
            // Declare new DataAccess object
            ManageCityDa dataAccess = new ManageCityDa();

            using (var transaction = new TransactionScope())
            {
                res = dataAccess.UpdateCity(city);
                if (res <= 0)
                {
                    transaction.Dispose();
                }
                transaction.Complete();
            }
            return(res);
        }
Пример #6
0
        public long UpdateCity(MstCity city)
        {
            long result = 0;

            //Check create new customer
            StringBuilder sqlinsert = new StringBuilder();

            city.DEL_FLG = DeleteFlag.NON_DELETE;

            sqlinsert.Append(@" 
                    UPDATE [dbo].[MstCity]
                    SET [CITY_ZIP_CD] = @CITY_ZIP_CD
                    ,[CITY_NAME] = @CITY_NAME
                    ,[DSP_ORDER] = @DSP_ORDER
                    ,[DEL_FLG] = @DEL_FLG
                    ,[STATUS] = @STATUS
                    WHERE [CITY_CD] = @CITY_CD");

            result = base.DbUpdate(sqlinsert.ToString(), city, new { CITY_CD = city.CITY_CD });
            return(result);
        }