Ejemplo n.º 1
0
        public IHttpActionResult PutUsers(Users users)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(users).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsersExists(users.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> PutCountryMaster(int id, CountryMaster countryMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != countryMaster.Id)
            {
                return(BadRequest());
            }

            db.Entry(countryMaster).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        private void UpdateNotFirstLogin(UserViewModel UserViewModelNew)
        {
            Users userModel = new Users
            {
                Id            = UserViewModelNew.Id,
                UserName      = UserViewModelNew.UserName,
                EmailId       = UserViewModelNew.EmailId,
                UserPassword  = UserViewModelNew.UserPassword,
                IsActive      = UserViewModelNew.IsActive,
                NotFirstLogin = false,
                //DateOfBirth = UserViewModelNew.DateOfBirth,
                FirstName = UserViewModelNew.FirstName,
                LastName  = UserViewModelNew.LastName,
                RoleId    = UserViewModelNew.RoleId,
                Status    = UserViewModelNew.Status,
                CountryId = UserViewModelNew.CountryId,
                ZoneId    = UserViewModelNew.ZoneId,
                BranchId  = UserViewModelNew.BranchId,
                StateId   = UserViewModelNew.StateId
            };

            db.Entry(userModel).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
            }
        }
Ejemplo n.º 4
0
        // PUT api/Student/5
        public IHttpActionResult PutStudent(int id, Student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != student.Id)
            {
                return(BadRequest());
            }

            db.Entry(student).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StudentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutSchoolMaster(SchoolMaster schoolMaster)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(schoolMaster).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                if (!SchoolMasterExists(schoolMaster.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 6
0
        public IHttpActionResult PutGeoHierarchy(GeoHierarchyViewModel geoHierarchyViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    GeoHierarchy geoHierarchy = geoHierarchyViewModel;
                    db.Entry(geoHierarchy).State = EntityState.Modified;
                    db.SaveChanges();
                    List <SchoolGeoHierarchyMapping> lstSchoolGeoHierarchyMapping = db.SchoolGeoHierarchyMapping.Where(a => a.GeoHierarchyId == geoHierarchyViewModel.Id).ToList();
                    db.SchoolGeoHierarchyMapping.RemoveRange(lstSchoolGeoHierarchyMapping);
                    db.SaveChanges();
                    lstSchoolGeoHierarchyMapping.Clear();
                    foreach (SchoolGeoHierarchyMappingViewModel item in geoHierarchyViewModel.SchoolGeoHierarchyMappingViewModels)
                    {
                        lstSchoolGeoHierarchyMapping.Add(new SchoolGeoHierarchyMapping {
                            SchoolId = Convert.ToInt32(item.Code), GeoHierarchyId = geoHierarchyViewModel.Id
                        });
                    }
                    db.SchoolGeoHierarchyMapping.AddRange(lstSchoolGeoHierarchyMapping);
                    db.SaveChanges();
                    transaction.Commit();
                }
                catch (DbUpdateConcurrencyException)
                {
                    transaction.Rollback();
                    if (!GeoHierarchyExists(geoHierarchyViewModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }