public async Task <bool> AddComplaint(int userId, int questionId, ComplaintType complaintType) { var complainttAddDate = DateTime.UtcNow; return(await _db.Database.ExecuteSqlCommandAsync( $"addComplaint {userId}, {questionId}, {complaintType}, {complainttAddDate}") > 0); }
public IActionResult ComplaintTypeUpdated(ComplaintType complainttype) { SessionCheck(); try { int exist = obj_hrpdbcontext.Complaint_Types.Count(x => x.name == complainttype.name); if (exist > 0) { throw new DbUpdateException(); } else { var updatequery = obj_hrpdbcontext.Complaint_Types .Where(x => x.id == complainttype.id) .FirstOrDefault(); updatequery.name = complainttype.name; obj_hrpdbcontext.SaveChanges(); } } catch (DbUpdateException) { return(RedirectToAction("IdExist")); } return(RedirectToAction("ComplaintTypeList")); }
public ActionResult Add(ComplaintType model) { try { if (ModelState.IsValid) { if (model.Code > 0) { var chk = _complaintType.GetAll().Where(c => c.Name.ToUpper() == model.Name.ToUpper() || c.Code == model.Code).FirstOrDefault(); if (chk == null) { _complaintType.Create(model); TempData["Msg"] = _help.getMsg(AlertType.success.ToString(), "Added successfully!"); return(RedirectToAction("Index")); } else { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = "The record already exist. Please check the records and try again!" })); } } else { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = "Invalid Code!" })); } } else { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = "Please fill the form correctly!" })); } } catch (Exception ex) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, Error = ex.Message })); } }
public static ComplaintType GetDetails(int id) { ComplaintType info = null; info = BaseDataAccess.GetRecords <ComplaintType>(string.Format("select * from ComplaintTypes where Id='{0}'", id)); return(info); }
public void UpdateComplaintType(ComplaintType complaintType) { DataContext.ComplaintTypes.Attach(complaintType); DataContext.Entry(complaintType).State = EntityState.Modified; SetAuditFields(complaintType); DataContext.SaveChanges(); }
//PENDING public IActionResult ComplaintTypeUpdate(int id) { SessionCheck(); ComplaintType complainttype = obj_hrpdbcontext.Complaint_Types.Where(data => data.id == id).FirstOrDefault(); return(View(complainttype)); }
public void DeleteComplaintType(long complaintTypeId) { ComplaintType complaintType = GetComplaintType(complaintTypeId); DataContext.ComplaintTypes.Remove(complaintType); DataContext.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { ComplaintType complaintType = db.ComplaintType.Find(id); db.ComplaintType.Remove(complaintType); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Total number of complaints of a certain type /// </summary> /// <param name="type">Type of Complaint</param> /// <returns>int</returns> public int NumberOfComplaints(ComplaintType type) { int count = 0; count = (from complaint in _context.Complaint where complaint.ComplaintType == type select complaint).Count(); return(count); }
public ActionResult Edit([Bind(Include = "IdComplaintType,Name")] ComplaintType complaintType) { if (ModelState.IsValid) { db.Entry(complaintType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(complaintType)); }
public ActionResult Create([Bind(Include = "IdComplaintType,Name")] ComplaintType complaintType) { if (ModelState.IsValid) { db.ComplaintType.Add(complaintType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(complaintType)); }
public ActionResult Create(ComplaintType complaintType) { try { _dbComplaintTypeRepository.Insert(complaintType); return(RedirectToAction("Index")); } catch { return(View(complaintType)); } }
public void Create(ComplaintType model) { try { _context.ComplaintTypes.Add(model); _context.SaveChanges(); } catch (Exception e) { throw; } }
public ActionResult Edit(int id, ComplaintType complaintType) { try { _dbComplaintTypeRepository.Update(complaintType); return(RedirectToAction("Index")); } catch { return(View(complaintType)); } }
// GET: ComplaintTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComplaintType complaintType = db.ComplaintType.Find(id); if (complaintType == null) { return(HttpNotFound()); } return(View(complaintType)); }
public ICollection <ComplaintType> GetData() { var command = _dbComplaintTypeCommandProvider.GetGetDataDbCommand(); command.Connection = _dbConnHolder.Connection; _dbConnHolder.Open(); var entList = new Collection <ComplaintType>(); var reader = new SafeDataReader(command.ExecuteReader(CommandBehavior.CloseConnection)); while (reader.Read()) { var tempEntity = new ComplaintType(reader.GetInt32("Id"), reader.GetString("Name")); entList.Add(tempEntity); } reader.Close(); return(entList); }
public void UpdateComplaintType(ComplaintType obj) { try { var dt = _context.ComplaintTypes.Find(obj.ComplaintTypeId); if (dt != null) { dt.Name = obj.Name; dt.Code = obj.Code; dt.Status = obj.Status; _context.SaveChanges(); } } catch (Exception e) { throw; } }
public bool AddComplaintType(ComplaintTypeVM model) { if (model == null) { throw new Exception("There is no Entry!"); } var data = new ComplaintType { ComplaintTypeId = model.complaintTypeId, DepartmentId = model.departmentId, ComplaintName = model.complaintName, }; _context.ComplaintType.Add(data); return(_context.SaveChanges() > 0); }
public PagedResult <ComplaintType> GetDataPageable(string sortExpression, int page, int pageSize) { var command = _dbComplaintTypeCommandProvider.GetGetDataPageableDbCommand(sortExpression, page, pageSize); command.Connection = _dbConnHolder.Connection; _dbConnHolder.Open(); var entList = new Collection <ComplaintType>(); var reader = new SafeDataReader(command.ExecuteReader(CommandBehavior.CloseConnection)); while (reader.Read()) { var tempEntity = new ComplaintType(reader.GetInt32("Id"), reader.GetString("Name")); entList.Add(tempEntity); } reader.Close(); var totalCount = GetRowCount(); var pagedResults = new PagedResult <ComplaintType>(page, pageSize, totalCount, entList); return(pagedResults); }
public IActionResult ComplaintTypeCreated(ComplaintType complainttype) { SessionCheck(); try { int exist = obj_hrpdbcontext.Complaint_Types.Count(x => x.name == complainttype.name); if (exist > 0) { throw new DbUpdateException(); } else { obj_hrpdbcontext.Complaint_Types.Add(complainttype); obj_hrpdbcontext.SaveChanges(); } } catch (DbUpdateException) { return(RedirectToAction("IdExist")); } return(RedirectToAction("ComplaintTypeList")); }
public void Update_Should_Update_A_ComplaintType() { _repository .Setup(it => it.Update(It.IsAny <string>(), It.IsAny <int>())) .Callback <string, int>((name, id) => { var tComplaintType = _repositoryList.Find(x => x.Id == id); tComplaintType.Name = name; }); var tempComplaintType = _repositoryList.Find(x => x.Id == Id); var testComplaintType = new ComplaintType { Id = tempComplaintType.Id, Name = tempComplaintType.Name }; //TODO change something on testComplaintType //testComplaintType.oldValue = newValue; _target.Update(testComplaintType); //Assert.AreEqual(newValue, _repositoryList.Find(x => x.Id==1).oldValue); //TODO fail until we update the test above Assert.Fail(); }
public void AddComplaintType(ComplaintType complaintType) { DataContext.ComplaintTypes.Add(complaintType); SetAuditFields(complaintType); DataContext.SaveChanges(); }
public static bool Update(ComplaintType info) { return(BaseDataAccess.ExecuteSQL(String.Format("update ComplaintTypes set Name='{1}',DepartmentTypeId='{2}'where Id={3}", info.Name, info.DepartmentTypeId, info.Id))); }
public static string Report(int aSourceId, ComplaintType aComplaintType) { return String.Format("/Complaint/Create?sourceId={0}&complaintType={1}", aSourceId, aComplaintType.ToString()); }
public async Task UsersReportAsync( uint userId , ComplaintType type , string comment ){ await Executor.ExecAsync( _reqapi.UsersReport( userId, type, comment ) ); }
public void Update(ComplaintType complaintType) { Update(complaintType.Name, complaintType.Id); }
public void Delete(ComplaintType complaintType) { Delete(complaintType.Id); }
public int Insert(ComplaintType complaintType) { return(_dbRepository.Insert(complaintType.Name)); }
public static bool Delete(ComplaintType info) { return(BaseDataAccess.ExecuteSQL(String.Format("Delete from ComplaintTypes where Id='{0}'", info.Id))); }
///<summary> /// Позволяет пожаловаться на пользователя /// ///</summary> ///<param name="userId">идентификатор пользователя, на которого нужно подать жалобу</param> ///<param name="type">тип жалобы</param> ///<param name="comment">комментарий к жалобе на пользователя</param> public Request<bool> Report( int userId , ComplaintType type , string comment ) { var req = new Request<bool>{ MethodName = "users.report", Parameters = new Dictionary<string, string> { { "user_id", userId.ToNCString()}, { "type", type.ToNCString().ToSnake()}, { "comment", comment}, } }; req.Token = _parent.CurrentToken; return req; }
public int Insert(ComplaintType complaintType) { return(Insert(complaintType.Name)); }
///<summary> /// Позволяет пожаловаться на пользователя /// ///</summary> ///<param name="userId">идентификатор пользователя, на которого нужно подать жалобу</param> ///<param name="type">тип жалобы</param> ///<param name="comment">комментарий к жалобе на пользователя</param> public async Task Report( int userId , ComplaintType type , string comment ) { await _parent.Executor.ExecAsync( _parent._reqapi.Users.Report( userId,type,comment ) ).ConfigureAwait(false) ; }
///<summary> /// Позволяет пожаловаться на пользователя /// ///</summary> ///<param name="userId">идентификатор пользователя, на которого нужно подать жалобу</param> ///<param name="type">тип жалобы</param> ///<param name="comment">комментарий к жалобе на пользователя</param> public void ReportSync( int userId , ComplaintType type , string comment ) { var task = _parent.Executor.ExecAsync( _parent._reqapi.Users.Report( userId,type,comment ) ); task.Wait(); }
public async Task <DTO> GetComplaintTypeData() { var data = await ComplaintType.ToListAsync(); return(SuccessResponse(data)); }
public VKRequest<StructEntity<int>> UsersReport( uint userId , ComplaintType type , string comment ){ var req = new VKRequest<StructEntity<int>>{ MethodName = "users.report", Parameters = new Dictionary<string, string> { { "user_id", userId.ToNCString() }, { "type", type.ToNClString() }, { "comment", comment } } }; req.Token = CurrentToken; return req; }
public ActionResult Create(ComplaintType complaintType, string complaint, int sourceId) { if (!IsLoggedIn()) { return RedirectToLogin(); } try { User myUser = GetUserInformaton(); switch (complaintType) { case ComplaintType.Issue: if (theService.IssueComplaint(myUser, complaint, sourceId)) { return SuccessfulComplaint(); } break; case ComplaintType.IssueReply: if (theService.IssueReplyComplaint(myUser, complaint, sourceId)) { return SuccessfulComplaint(); } break; case ComplaintType.IssueReplyComment: if (theService.IssueReplyCommentComplaint(myUser, complaint, sourceId)) { return SuccessfulComplaint(); } break; case ComplaintType.ProfileComplaint: if (theService.ProfileComplaint(myUser, complaint, sourceId)) { return SuccessfulComplaint(); } break; case ComplaintType.PhotoComplaint: if (theService.PhotoComplaint(myUser, complaint, sourceId)) { return SuccessfulComplaint(); } break; } } catch (Exception e) { LogError(e, "Error logging report. Please try again."); TempData["Message"] += MessageHelper.ErrorMessage("Error logging report. Please try again."); TempData["ComplaintBody"] = complaint; } return RedirectToAction("Create", new { complaintType = complaintType, sourceId = sourceId }); }
public void Update(ComplaintType complaintType) { _dbRepository.Update(complaintType.Name, complaintType.Id); }
public Builder(int aSourceId, ComplaintType aComplaintType) { theSourceId = aSourceId; theComplaintType = aComplaintType; theTowardUser = new User(); theSourceDescription = string.Empty; theComplaint = string.Empty; }