public ActionResult ApproveDeal(Int64 Id) { ResponseModel _response = new ResponseModel(); var details = _dealRepository.FindBy(x => x.DealId == Id).FirstOrDefault(); details.Status = (int)Status.Active; details.ModifiedDate = DateTime.Now; details.ModifiedBy = UserAuthenticate.UserId; bool IsTrue = _dealRepository.Update(details); _dealRepository.SaveChanges(); if (IsTrue) { _response.Type = "success"; _response.Message = "Deal approved successfully"; } else { _response.Type = "error"; _response.Message = "Somehing went wrong"; } return(Json(_response, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage CreateDeal(DealModel dealModel) { ResponseModel _response = new ResponseModel(); var model = Mapper.Map <DealModel, Deal>(dealModel); model.CreatedDate = DateTime.Now; model.Status = (int)Status.Created; model.IsDeleted = false; _dealRepository.Add(model); int Rows = _dealRepository.SaveChanges(); if (Rows > 0) { if (dealModel.lstSchemes != null && dealModel.lstSchemes.Count > 0) { // Scheme not mandatory List <Scheme> schemes = new List <Scheme>(); foreach (var item in dealModel.lstSchemes) { Scheme objScheme = new Scheme(); objScheme.DealId = model.DealId; objScheme.SchemeTypeId = item.SchemeTypeId; objScheme.MinOrderQuantity = item.MinOrderQuantity; objScheme.DealRate = item.DealRate; objScheme.Saving = item.Saving; objScheme.DealScheme = item.DealScheme; objScheme.Status = (int)Status.Created; objScheme.IsDeleted = false; objScheme.CreatedBy = item.CreatedBy; objScheme.CreatedDate = DateTime.Now; schemes.Add(objScheme); } _schemeRepository.SaveList(schemes); _schemeRepository.SaveChanges(); } // For Uploading image ---- if (dealModel.DocProduct != null) { UploadDocumentModel UploadDocument = new UploadDocumentModel(); UploadDocument.documents = new List <DocumentModel>(); UploadDocument.ImageSize = 250; UploadDocument.ImageQuality = 250; UploadDocument.documents.Add(dealModel.DocProduct); List <string> uploadedFileName = SavePicture(UploadDocument); if (uploadedFileName.Count > 0) { Deal _deal = _dealRepository.FindBy(x => x.DealId == model.DealId).FirstOrDefault(); if (_deal != null) { _deal.ProductImagePath = uploadedFileName[0].ToString(); _dealRepository.Update(_deal); _dealRepository.SaveChanges(); } } } _response.Type = "success"; _response.Message = "Scheme added successfully"; return(Request.CreateResponse(HttpStatusCode.OK, _response)); } else { _response.Type = "error"; _response.Message = "Something went wrong"; return(Request.CreateResponse(HttpStatusCode.OK, _response)); } }