public ActionResult Edit([Bind(Include = "roleID,name,active,createDate,createUser,updateDate,updateUser,selected")] Role role)
 {
     try
     {
         if (DataUtil.Validation())
         {
             if (ModelState.IsValid)
             {
                 role.updateDate      = DateTime.Now;
                 role.updateUser      = Helper.GetCurrentUser().userID;
                 db.Entry(role).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             return(View(role));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         Error objError = new Error();
         objError.page        = "Roles";
         objError.option      = "Edit-2";
         objError.date        = DateTime.Now;
         objError.description = ex.Message;
         BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
         baseDataAccess.Insert(objError);
         return(RedirectToAction("Error", "Home"));
     }
 }
 public ActionResult Edit([Bind(Include = "apartmentID,sectionID,name,active,createDate,createUser,updateDate,updateUser")] Apartment apartment)
 {
     try
     {
         if (DataUtil.Validation())
         {
             if (ModelState.IsValid)
             {
                 apartment.updateDate      = DateTime.Now;
                 apartment.updateUser      = Helper.GetCurrentUser().userID;
                 db.Entry(apartment).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index", new { id = apartment.sectionID }));
             }
             //ViewBag.sectionID = new SelectList(db.Section, "sectionID", "name", apartment.sectionID);
             ViewBag.BuildingName = apartment.section.name;
             return(View(apartment));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         Error objError = new Error();
         objError.page        = "Apartments";
         objError.option      = "Edit-2";
         objError.date        = DateTime.Now;
         objError.description = ex.Message;
         BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
         baseDataAccess.Insert(objError);
         return(RedirectToAction("Error", "Home"));
     }
 }
 public ActionResult Edit([Bind(Include = "postID,postCategoryID,title,content,active,createDate,createUser,updateDate,updateUser")] Post post)
 {
     try
     {
         if (DataUtil.Validation())
         {
             if (ModelState.IsValid)
             {
                 db.Entry(post).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             ViewBag.postCategoryID = new SelectList(db.PostCategory, "postCategoryID", "name", post.postCategoryID);
             return(View(post));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         Error objError = new Error();
         objError.page        = "Post";
         objError.option      = "Edit-2";
         objError.date        = DateTime.Now;
         objError.description = ex.Message;
         BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
         baseDataAccess.Insert(objError);
         return(RedirectToAction("Error", "Home"));
     }
 }
 public ActionResult Edit([Bind(Include = "buildingID,name,address,addressReference,country,state,city,district,apartmentQuantity,active,createDate,createUser,updateDate,updateUser")] Building building)
 {
     try
     {
         if (DataUtil.Validation())
         {
             if (ModelState.IsValid)
             {
                 building.updateDate      = DateTime.Now;
                 building.updateUser      = Helper.GetCurrentUser().userID;
                 db.Entry(building).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             return(View(building));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         Error objError = new Error();
         objError.page        = "Buildings";
         objError.option      = "Edit-2";
         objError.date        = DateTime.Now;
         objError.description = ex.Message;
         BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
         baseDataAccess.Insert(objError);
         return(RedirectToAction("Error", "Home"));
     }
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Architect")] BuildingModel buildingModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(buildingModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(buildingModel));
 }
        public void EditBuilding()
        {
            var editingBuilding = _db.Buildings.Find(SelectedItem.Id);

            editingBuilding.Year        = Year;
            editingBuilding.CountFloors = CountFloors;

            _db.Entry(editingBuilding).State = EntityState.Modified;
            _db.SaveChanges();

            var editingVertex = Vertices.First(vertex => vertex.Id == editingBuilding.Id);

            editingVertex.X = CountFloors;
            editingVertex.Y = Year;

            ToStartState();
        }
Beispiel #7
0
        public ActionResult UpdatePassword(User objUser)
        {
            try
            {
                if (objUser.username == "" || objUser.password == "" || objUser.newpassword == "" || objUser.username == null || objUser.password == null || objUser.newpassword == null)
                {
                    objUser.result = 3;
                }
                else
                {
                    User oUser = new User();

                    oUser = db.User.FirstOrDefault(u => u.username.ToUpper() == objUser.username.ToUpper() && u.password == objUser.password);

                    if (objUser != null)
                    {
                        oUser.password        = objUser.newpassword;
                        db.Entry(oUser).State = EntityState.Modified;
                        db.SaveChanges();
                        objUser.result = 1;
                    }
                    else
                    {
                        objUser.result = 2;
                    }
                }
                return(View(objUser));
            }
            catch (Exception ex)
            {
                Error objError = new Error();
                objError.page        = "Home";
                objError.option      = "UpdatePassword-2";
                objError.date        = DateTime.Now;
                objError.description = ex.Message;
                BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
                baseDataAccess.Insert(objError);
                return(RedirectToAction("Error", "Home"));
            }
        }
Beispiel #8
0
 public ActionResult Edit(User user)
 {
     try
     {
         if (DataUtil.Validation())
         {
             if (ModelState.IsValid)
             {
                 BaseDataAccess <User> objBaseDatosAccess = new BaseDataAccess <User>();
                 objBaseDatosAccess.Update(user);
                 ApartmentUser objApartmentUser = new ApartmentUser();
                 objApartmentUser.apartmentID = user.apartmentID;
                 objApartmentUser.userID      = user.userID;
                 objApartmentUser.principal   = user.principal;
                 db.Entry(user).State         = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index", new { id = user.apartmentID }));
             }
             return(View(user));
         }
         else
         {
             return(RedirectToAction("Login", "Home"));
         }
     }
     catch (Exception ex)
     {
         Error objError = new Error();
         objError.page        = "ApartmentUsers";
         objError.option      = "Edit-2";
         objError.date        = DateTime.Now;
         objError.description = ex.Message;
         BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
         baseDataAccess.Insert(objError);
         return(RedirectToAction("Error", "Home"));
     }
 }
        public ActionResult Profile([Bind(Include = "userID,categoryUserID,name,lastname,username,password,active,email,dni,phonenumber,createDate,createUser,updateDate,updateUser")] User user, HttpPostedFileBase postedFile)
        {
            try
            {
                if (DataUtil.Validation())
                {
                    if (ModelState.IsValid)
                    {
                        var objUserEmail = db.User.FirstOrDefault(u => u.email == user.email && u.userID != user.userID);
                        if (objUserEmail != null)
                        {
                            user.messageErrorEmail = "El email ingresado ya existe!.";
                        }
                        else
                        {
                            user.updateDate = DateTime.Now;
                            user.updateUser = Helper.GetCurrentUser().userID;
                            user.name       = user.name.ToUpper();
                            user.lastname   = user.lastname.ToUpper();

                            user.imageURL        = System.Configuration.ConfigurationManager.AppSettings["userImgURL"] + user.userID.ToString() + ".jpg";
                            db.Entry(user).State = EntityState.Modified;
                            db.SaveChanges();

                            if (postedFile != null)
                            {
                                var    versions = new Dictionary <string, string>();
                                string path     = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["userImgURLFinal"]);
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                postedFile.SaveAs(path + Helper.GetCurrentUser().userID.ToString() + Path.GetExtension(postedFile.FileName));
                                versions.Add("", "maxwidth=120&maxheight=120&format=jpg");
                                foreach (var suffix in versions.Keys)
                                {
                                    postedFile.InputStream.Seek(0, SeekOrigin.Begin);
                                    ImageBuilder.Current.Build(
                                        new ImageJob(
                                            postedFile.InputStream,
                                            path + user.userID.ToString() + suffix,
                                            new Instructions(versions[suffix]),
                                            false,
                                            true));
                                }
                                ViewBag.Message = "File uploaded successfully.";
                            }
                        }
                        return(RedirectToAction("Profile"));
                    }
                    return(View(user));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
            catch (Exception ex)
            {
                Error objError = new Error();
                objError.page        = "Users";
                objError.option      = "Edit-2";
                objError.date        = DateTime.Now;
                objError.description = ex.Message;
                BaseDataAccess <Error> baseDataAccess = new BaseDataAccess <Error>();
                baseDataAccess.Insert(objError);
                return(RedirectToAction("Error", "Home"));
            }
        }