public JsonResult SaveFollowUp(DateTime followUpDate, string comment, int customerId, bool isBroker) { try { var lastCrm = this._customerRelationsRepository.GetLastCrm(customerId); var followUp = new CustomerRelationFollowUp { Comment = comment, CustomerId = customerId, DateAdded = DateTime.UtcNow, FollowUpDate = followUpDate, IsBroker = isBroker, }; this._customerRelationFollowUpRepository.SaveOrUpdate(followUp); this._customerRelationStateRepository.SaveUpdateState(customerId, true, followUp, lastCrm); return(Json(new { success = true, error = "" })); } catch (Exception e) { Log.Error("Exception while trying to save customer relations new entry.", e); return(Json(new { success = false, error = "Error saving new customer relations follow up." })); } // try } // SaveFollowUp
public JsonResult CloseFollowUp(int customerId, int?followUpId = null) { try { var lastCrm = this._customerRelationsRepository.GetLastCrm(customerId); CustomerRelationFollowUp lastFollowUp = followUpId == null ? this._customerRelationFollowUpRepository.GetLastFollowUp(customerId) : this._customerRelationFollowUpRepository.Get(followUpId); if (lastFollowUp == null) { return(Json(new { success = false, error = "customer don't have any open follow ups please add one." })); } lastFollowUp.IsClosed = true; lastFollowUp.CloseDate = DateTime.UtcNow; this._customerRelationStateRepository.SaveUpdateState(customerId, false, lastFollowUp, lastCrm); return(Json(new { success = true, error = "" })); } catch (Exception e) { Log.ErrorFormat("Exception while trying to close customer relations follow up:{0}", e); return(Json(new { success = false, error = "Error saving new customer relations follow up." })); } // try } // CloseFollowUp