Exemple #1
0
        public bool UpdateComplaintType(ComplaintTypeVM model)
        {
            var data = (from x in _context.ComplaintType
                        where x.ComplaintTypeId == model.complaintTypeId
                        select x).FirstOrDefault();

            if (data == null)
            {
                throw new Exception("Record not found");
            }

            data.ComplaintTypeId = model.complaintTypeId;
            data.DepartmentId    = model.departmentId;
            data.ComplaintName   = model.complaintName;

            return(_context.SaveChanges() > 0);
        }
Exemple #2
0
        public HttpResponseMessage UpdateComplaintType(ComplaintTypeVM model)
        {
            try
            {
                var response = _repo.UpdateComplaintType(model);

                if (response == false)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "No record found" }));
                }
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = response }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = ex.Message }));
            }
        }
Exemple #3
0
        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);
        }