コード例 #1
0
        /// <summary>
        /// Insert/Update Regiosn Picklist
        /// </summary>
        /// <param name="se"></param>
        /// <returns></returns>
        public async Task <bool> RegionsUpdateAsync(PicklistRegions se)
        {
            bool result = true;

            using (_context)
            {
                try
                {
                    var model = await _context.PicklistRegions.FirstOrDefaultAsync(p => p.RegID == se.RegID);

                    if (model == null)
                    {
                        _context.PicklistRegions.Add(se);
                    }
                    else
                    {
                        _context.PicklistRegions.Update(se);
                    }

                    await _context.SaveChangesAsync();
                }
                catch (Exception)
                {
                    result = false;
                }
            }
            return(result);
        }
コード例 #2
0
        public async Task <ActionResult <PicklistRegions> > PostRegions([FromBody] SimpleModel list)
        {
            PicklistRegions model    = Newtonsoft.Json.JsonConvert.DeserializeObject <PicklistRegions>(list.Name);
            var             response = this.StatusCode((int)HttpStatusCode.OK, await _service.RegionsUpdateAsync(model));

            _service.Dispose();
            return(response);
        }