public HttpResponseMessage Add(OpportunityAddRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } ItemResponse <int> response = new ItemResponse <int>(); response.Item = _opportunity.Insert(model); return(Request.CreateResponse(HttpStatusCode.OK, response)); }
public ActionResult Create(OpportunityViewModel opportunity) { if (ModelState.IsValid) { var entity = Mapper.Map <Opportunity>(opportunity); //view modelden alınanı entity e dönüştürüyor. opportunityService.Insert(entity); return(RedirectToAction("Index")); } ViewBag.CampaignSourceId = new SelectList(campaignSourceService.GetAll(), "Id", "Name"); ViewBag.CompanyId = new SelectList(companyService.GetAll(), "Id", "Owner"); ViewBag.ContactId = new SelectList(contactService.GetAll(), "Id", "Owner"); ViewBag.LeadSourceId = new SelectList(leadSourceService.GetAll(), "Id", "Name"); return(View(opportunity)); }
public ActionResult AddOpportunity(decimal opportunityAmount, OpportunityStage opportunityStage, DateTime opportunityCloseDate, Guid companyId, string opportunityName) { try { var opportunity = new Opportunity(); opportunity.Amount = opportunityAmount; opportunity.OpportunityStage = opportunityStage; opportunity.CloseDate = opportunityCloseDate; opportunity.CompanyId = companyId; opportunity.Name = opportunityName; opportunityService.Insert(opportunity); return(Json(true)); } catch (Exception ex) { return(Json(false)); } }