public ActionResult Settings(UZYTKOWNIK uzytkownikToEdit) { int id = (int)Session["UserID"]; var temp = ((from UZYTKOWNIK in dbUzytkownik.UZYTKOWNIK where UZYTKOWNIK.UZ_id == id select UZYTKOWNIK).First()); if (!ModelState.IsValid) { return(View(temp)); } dbUzytkownik.Entry(temp).CurrentValues.SetValues(uzytkownikToEdit); dbUzytkownik.SaveChanges(); return(RedirectToAction("Index", "User")); }
/// <summary> /// 删除实时监测数据位置信息 /// </summary> public ReturnItem <RetRealTimeMonitor> DeleteData(RealTimeMonitorModel parameter) { ReturnItem <RetRealTimeMonitor> r = new ReturnItem <RetRealTimeMonitor>(); using (UserEntities user = new UserEntities()) { try { var deletechart = user.U_HomeConfiguration.Where(s => s.ID == parameter.ID).FirstOrDefault(); if (deletechart != null) { var entry = user.Entry(deletechart); //设置该对象的状态为删除 entry.State = EntityState.Deleted; user.SaveChanges(); //保存修改 } r.Msg = "图表删除成功"; r.Code = 0; } catch (Exception e) { r.Msg = "内部错误请重试"; log.ErrorFormat("内部错误:{0},{1}", e.Message, e.StackTrace); r.Code = -1; } } return(r); }
public IHttpActionResult PutUserInfo(int id, UserInfo userInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userInfo.UserID) { return(BadRequest()); } db.Entry(userInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,EmailID,City,Country")] Emplyoee emplyoee) { if (ModelState.IsValid) { db.Entry(emplyoee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(emplyoee)); }
public ActionResult Edit([Bind(Include = "userID,firstName,lastName,userEmail")] userdata userdata) { if (ModelState.IsValid) { db.Entry(userdata).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("View_Climbers")); } return(View(userdata)); }
public ActionResult Edit([Bind(Include = "Id,UserName,Password,Email")] User user) { if (ModelState.IsValid) { Context.Entry(user).State = EntityState.Modified; Context.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public void AddDynamicFieldData(BacklogFormDataDTO item, int id) { UserEntities db = new UserEntities(); var isAdded = db.cmatrix_contact_form_data.Where(x => x.ccfd_ccb_key == id && x.ccfd_ccftd_key == item.elementId).FirstOrDefault(); if (isAdded != null) { isAdded.ccfd_data = item.FieldValue; db.Entry(isAdded).State = EntityState.Modified; db.SaveChanges(); } else { cmatrix_contact_form_data data = new cmatrix_contact_form_data(); data.ccfd_data = item.FieldValue; data.ccfd_ccftd_key = item.elementId; data.ccfd_ccb_key = id; db.cmatrix_contact_form_data.Add(data); db.SaveChanges(); } }
/// <summary> /// 批量删除消息信息 /// </summary> public ReturnItem <RetMessageInfo> DelMessageInfo(List <MessageInfoModel> parameter, string UserID) { ReturnItem <RetMessageInfo> r = new ReturnItem <RetMessageInfo>(); using (UserEntities user = new UserEntities()) { try { var list = new List <string>(); foreach (var item in parameter) { list.Add(item.ID.ToString()); } var userid = Convert.ToInt32(UserID); var deluser = user.U_UserMessageRel.Where(s => s.UserID == userid && list.Contains(s.MessageID.ToString())).AsQueryable <U_UserMessageRel>(); if (deluser != null) { foreach (var item in deluser) { var entry = user.Entry(item); //设置该对象的状态为删除 entry.State = EntityState.Deleted; } user.SaveChanges(); //保存修改 r.Msg = "信息删除成功"; r.Code = 0; } } catch (Exception e) { r.Msg = "内部错误请重试"; log.ErrorFormat("内部错误:{0},{1}", e.Message, e.StackTrace); r.Code = -1; } } return(r); }
public int AddcontactId(BacklogFormDataDTO item, int id) { UserEntities db = new UserEntities(); int contactid = id; if (id == 0) { cmatrix_contact contact = new cmatrix_contact(); contact.ccf_name = item.FieldValue; contact.ccf_created_date = DateTime.Now; db.cmatrix_contact.Add(contact);; db.SaveChanges(); contactid = contact.ccf_key; } else { var ids = db.cmatrix_contact.Where(x => x.ccf_key == id).FirstOrDefault(); ids.ccf_name = item.FieldValue; db.Entry(ids).State = EntityState.Modified; db.SaveChanges(); } return(contactid); }
/// <summary> /// 实时监控页面新增数据位置 /// </summary> public ReturnItem <RetRealTimeMonitor> AddRealTimeMonitor(RealTimeMonitorModel parameter) { ReturnItem <RetRealTimeMonitor> r = new ReturnItem <RetRealTimeMonitor>(); using (UserEntities user = new UserEntities()) { try { var OrgID = Convert.ToInt32(parameter.OrgID); var DashBoardType = Convert.ToInt32(parameter.DashBoardType); // 2设备,3总览 var addmonitor = user.U_HomeConfiguration.Where(s => s.OrgID == OrgID && s.DashBoardType == DashBoardType).AsQueryable(); if ("2".Equals(parameter.DashBoardType)) // 设备 { var DeviceID = Convert.ToInt32(parameter.DeviceID); if ("0".Equals(parameter.ChartType)) { addmonitor = addmonitor.Where(s => s.DeviceID == DeviceID && s.ChartType == 0); } else if ("1".Equals(parameter.ChartType) || "2".Equals(parameter.ChartType)) { addmonitor = addmonitor.Where(s => s.DeviceID == DeviceID && s.DashBoardData == parameter.DashBoardData); } } else if ("3".Equals(parameter.DashBoardType)) // 总览 { if ("0".Equals(parameter.ChartType)) { addmonitor = addmonitor.Where(s => s.ChartType == 0); } else if ("1".Equals(parameter.ChartType) || "2".Equals(parameter.ChartType)) { addmonitor = addmonitor.Where(s => s.DashBoardData == parameter.DashBoardData); } } addmonitor = addmonitor.OrderByDescending(s => s.CreateTime); if (addmonitor.ToList().Count != 0) { if ("1".Equals(parameter.ChartType) || "2".Equals(parameter.ChartType))// 0 背景图信息 1 设备信息 2 设备属性信息 { r.Data = null; r.Code = -1; r.Msg = "该位置数据信息已存在"; return(r); } else if ("0".Equals(parameter.ChartType)) { if ("2".Equals(parameter.DashBoardType)) // 设备 { var DeviceID = Convert.ToInt32(parameter.DeviceID); var editmonitor = user.U_HomeConfiguration.Where(s => s.OrgID == OrgID && s.DashBoardType == DashBoardType && s.DeviceID == DeviceID && s.ChartType == 0).FirstOrDefault(); editmonitor.DashBoardData = parameter.DashBoardData; editmonitor.Remark = parameter.Remark; user.SaveChanges(); } else if ("3".Equals(parameter.DashBoardType)) // 总览 { var editmonitor = user.U_HomeConfiguration.Where(s => s.OrgID == OrgID && s.DashBoardType == DashBoardType && s.ChartType == 0).FirstOrDefault(); editmonitor.DashBoardData = parameter.DashBoardData; editmonitor.Remark = parameter.Remark; user.SaveChanges(); } if (parameter.DelDeviceTags.Count != 0) { foreach (var deltags in parameter.DelDeviceTags) { var delid = Convert.ToInt32(deltags); var deletechart = user.U_HomeConfiguration.Where(s => s.ID == delid).FirstOrDefault(); if (deletechart != null) { var entry = user.Entry(deletechart); //设置该对象的状态为删除 entry.State = EntityState.Deleted; user.SaveChanges(); //保存修改 } } } if (parameter.DelTags.Count != 0) { foreach (var deltags in parameter.DelTags) { var delid = Convert.ToInt32(deltags); var deletechart = user.U_HomeConfiguration.Where(s => s.ID == delid).FirstOrDefault(); if (deletechart != null) { var entry = user.Entry(deletechart); //设置该对象的状态为删除 entry.State = EntityState.Deleted; user.SaveChanges(); //保存修改 } } } r.Msg = "更新成功"; r.Code = 0; return(r); } } else if (addmonitor.ToList().Count == 0) { U_HomeConfiguration newChart = new U_HomeConfiguration() { DashBoardType = DashBoardType, // 2设备,3总览 ChartType = Convert.ToInt32(parameter.ChartType), // 0 背景图信息 1 设备信息 2 设备属性信息 DashBoardData = parameter.DashBoardData, Remark = parameter.Remark, CreateTime = DateTime.Now, CreateUserID = Convert.ToInt32(parameter.CreateUserID), OrgID = Convert.ToInt32(parameter.OrgID) }; if (parameter.DeviceID != "" && parameter.DeviceID != null) { newChart.DeviceID = Convert.ToInt32(parameter.DeviceID); } if (parameter.DeviceItemID != "" && parameter.DeviceItemID != null) { newChart.DeviceItemID = Convert.ToInt32(parameter.DeviceItemID); } if (parameter.GroupID != "" && parameter.GroupID != null) { newChart.GroupID = Convert.ToInt32(parameter.GroupID); } user.U_HomeConfiguration.Add(newChart); user.SaveChanges(); r.Msg = "新增成功"; r.Code = 0; } } catch (Exception e) { r.Msg = "内部错误请重试"; log.ErrorFormat("内部错误:{0},{1}", e.Message, e.StackTrace); r.Code = -1; } } return(r); }
public void SaveUpdateGridInfo(ColumnGridDetailsDto GridDetails, string TableName) { UserEntities db = new UserEntities(); var checkUserTableExists = db.ColumnUsersSettings.Where(x => x.GridName == TableName).ToList(); try { // Update Entries if record found if (checkUserTableExists.Count() > 0 && checkUserTableExists != null) { int ColumnOrder = 1; // update visible columns properties foreach (var item in GridDetails.visibleColumns) { var gridColumn = db.ColumnUsersSettings.Where(x => x.GridName == TableName && x.ColumnText == item.ColumnText).FirstOrDefault(); if (gridColumn == null) { SaveColumnData(ColumnOrder, item, TableName); } else { gridColumn.IsVisible = true; gridColumn.ColumnWidth = item.ColumnWidth; gridColumn.ColumnOrder = item.OrderBy; gridColumn.ColumnText = item.ColumnText; db.Entry(gridColumn).State = EntityState.Modified; db.SaveChanges(); } ColumnOrder = ColumnOrder + 1; } //update hidden columns properties foreach (var item in GridDetails.hiddenColumns) { var gridColumn = db.ColumnUsersSettings.Where(x => x.GridName == TableName && x.ColumnText == item.ColumnText).FirstOrDefault(); if (gridColumn == null) { SaveColumnData(0, item, TableName); } else { gridColumn.IsVisible = false; gridColumn.ColumnWidth = item.ColumnWidth; gridColumn.ColumnOrder = item.OrderBy; gridColumn.ColumnText = item.ColumnText; db.Entry(gridColumn).State = EntityState.Modified; db.SaveChanges(); } } } // Save Entries if record not found else { int ColumnOrder = 1; // save visible columns properties foreach (var item in GridDetails.visibleColumns) { // get default column values against table name and matching column name var defaultColumnValues = db.ColumnUsersSettings.Where(x => x.ColumnText == item.ColumnText && x.GridName == TableName).FirstOrDefault(); ColumnUsersSetting gridColumn = new ColumnUsersSetting(); gridColumn.IsVisible = true; gridColumn.ColumnWidth = item.ColumnWidth; gridColumn.ColumnOrder = ColumnOrder; gridColumn.ColumnText = item.ColumnText; gridColumn.GridName = TableName; gridColumn.ColumnType = defaultColumnValues.ColumnType; gridColumn.ColumnFilterId = defaultColumnValues.ColumnFilterId; db.ColumnUsersSettings.Add(gridColumn); db.SaveChanges(); ColumnOrder = ColumnOrder + 1; } // save hidden columns properties foreach (var item in GridDetails.hiddenColumns) { // get default column values against table name and matching column name var defaultColumnValues = db.ColumnUsersSettings.Where(x => x.ColumnText == item.ColumnText && x.GridName == TableName).FirstOrDefault(); ColumnUsersSetting gridColumn = new ColumnUsersSetting(); gridColumn.IsVisible = false; gridColumn.ColumnWidth = item.ColumnWidth; gridColumn.ColumnOrder = 0; gridColumn.ColumnText = item.ColumnText; gridColumn.GridName = TableName; gridColumn.ColumnType = defaultColumnValues.ColumnType; gridColumn.ColumnFilterId = defaultColumnValues.ColumnFilterId; db.ColumnUsersSettings.Add(gridColumn); db.SaveChanges(); } } } catch (Exception ex) { throw; } }
public ActionResult UserProfile(ProfileViewModel model) { UserEntities db = new UserEntities(); HomeService homeService = new HomeService(); if (ModelState.IsValid) { if (model.Userid > 0) { var userlist = db.tbl_user.Where(x => x.Userid == model.Userid).FirstOrDefault(); userlist.Userid = model.Userid; userlist.Username = model.Username; userlist.Email = model.Email; userlist.Password = model.Password; userlist.CityIds = string.Join(",", model.Cityids); //this is for multi select dropdown userlist.cityid = model.Cityid; //this is for simple dropdown userlist.Gender = model.Gender; userlist.Startdate = Convert.ToDateTime(model.StartDate); userlist.Enddate = Convert.ToDateTime(model.EndDate); userlist.IsCsharp = model.IsCsharp == null ? false : model.IsCsharp; userlist.IsJava = model.IsJava == null ? false : model.IsJava; userlist.IsPaython = model.IsPaython == null ? false : model.IsPaython; userlist.CountryID = model.SelectedCountry; userlist.StateId = model.SelectedState; if (model.UserImageFile != null) { string filename = Path.GetFileNameWithoutExtension(model.UserImageFile.FileName); string extension = Path.GetExtension(model.UserImageFile.FileName); filename = filename + DateTime.Now.ToString("yymmssff") + extension; userlist.ImagePath = "~/Image/" + filename; filename = Path.Combine(Server.MapPath("~/Image/"), filename); model.UserImageFile.SaveAs(filename); } db.Entry(userlist).State = System.Data.Entity.EntityState.Modified; } else { var user = new tbl_user(); if (model.UserImageFile != null) { string filename = Path.GetFileNameWithoutExtension(model.UserImageFile.FileName); string extension = Path.GetExtension(model.UserImageFile.FileName); filename = filename + DateTime.Now.ToString("yymmssff") + extension; user.ImagePath = "~/Image/" + filename; filename = Path.Combine(Server.MapPath("~/Image/"), filename); model.UserImageFile.SaveAs(filename); } user.Username = model.Username; user.Email = model.Email; user.Password = model.Password; user.cityid = model.Cityid;//this is for simple dropdown user.Gender = model.Gender; user.Startdate = Convert.ToDateTime(model.StartDate); user.Enddate = Convert.ToDateTime(model.EndDate); user.IsCsharp = model.IsCsharp == null ? false : model.IsCsharp; user.IsJava = model.IsJava == null ? false : model.IsJava; user.IsPaython = model.IsPaython == null ? false : model.IsPaython; user.CityIds = model.Cityids == null ? string.Empty : string.Join(",", model.Cityids); user.CountryID = model.SelectedCountry; user.StateId = model.SelectedState; db.tbl_user.Add(user); } db.SaveChanges(); return(RedirectToAction("Index")); } //var city = db.tbl_city.ToList(); model.Cities = db.tbl_city.Select(x => new citymodel { cityid = x.Cityid, cityname = x.Cityname }).ToList(); model.Countries = homeService.CountryStateList("Country"); model.SelectedCountry = 233; model.States = homeService.CountryStateList("states"); model.SelectedState = 1456;// new SelectList(city, "Cityid", "Cityname"); return(View(model)); }
public JsonResult AddUpdateContactTemplateElement(int elemId, int attrType, string name, string info, string FieldLabel, int colspan, int ddlType, string ddlListType, string OptionsList, bool isReq, string tabType, string FieldPlaceholder, string FieldErrorMessage, string buttonText) { UserEntities db = new UserEntities(); try { cmatrix_contact_form_template_details objcmatrix_backlog_form_template_details = new cmatrix_contact_form_template_details(); if (elemId > 0) { objcmatrix_backlog_form_template_details = db.cmatrix_contact_form_template_details.Where(x => x.ccftd_key == elemId).FirstOrDefault(); if (objcmatrix_backlog_form_template_details.ccftd_ddl_type == 3 && ddlType != 3) { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } objcmatrix_backlog_form_template_details = db.cmatrix_contact_form_template_details.Where(x => x.ccftd_key == elemId).FirstOrDefault(); objcmatrix_backlog_form_template_details.ccftd_field_name = name; objcmatrix_backlog_form_template_details.ccftd_field_label = FieldLabel; objcmatrix_backlog_form_template_details.ccftd_field_info = info; objcmatrix_backlog_form_template_details.ccftd_col_span = colspan; objcmatrix_backlog_form_template_details.ccftd_options = OptionsList; objcmatrix_backlog_form_template_details.ccftd_ddl_type = ddlType; objcmatrix_backlog_form_template_details.ccftd_field_placeholder = FieldPlaceholder; objcmatrix_backlog_form_template_details.ccftd_is_req = isReq; if (!string.IsNullOrEmpty(FieldErrorMessage) && isReq) { objcmatrix_backlog_form_template_details.ccftd_error_message = FieldErrorMessage; } else { objcmatrix_backlog_form_template_details.ccftd_error_message = ""; } db.Entry(objcmatrix_backlog_form_template_details).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { var highestOrder = db.cmatrix_contact_form_template_details.Select(x => x.ccftd_order).DefaultIfEmpty(0).Max(); objcmatrix_backlog_form_template_details.ccftd_attr_type = attrType; objcmatrix_backlog_form_template_details.ccftd_field_name = name; objcmatrix_backlog_form_template_details.ccftd_field_label = FieldLabel; objcmatrix_backlog_form_template_details.ccftd_field_info = info; objcmatrix_backlog_form_template_details.ccftd_col_span = colspan; objcmatrix_backlog_form_template_details.ccftd_options = OptionsList; objcmatrix_backlog_form_template_details.ccftd_ddl_type = ddlType; objcmatrix_backlog_form_template_details.ccftd_field_placeholder = FieldPlaceholder; objcmatrix_backlog_form_template_details.ccftd_is_req = isReq; objcmatrix_backlog_form_template_details.ccftd_is_active = true; objcmatrix_backlog_form_template_details.ccftd_is_default = false; objcmatrix_backlog_form_template_details.ccftd_error_message = FieldErrorMessage; objcmatrix_backlog_form_template_details.ccftd_cab_type = 47; objcmatrix_backlog_form_template_details.ccftd_cmp_key = 1; objcmatrix_backlog_form_template_details.ccftd_tab_type = Convert.ToInt32(tabType); objcmatrix_backlog_form_template_details.ccftd_order = highestOrder + 1; db.cmatrix_contact_form_template_details.Add(objcmatrix_backlog_form_template_details); db.SaveChanges(); } return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(false)); } }
public virtual void Update(T entity) { dbSet.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }