public async Task <IActionResult> CreateTransferFlow([FromBody] SaveTransferFlowResource saveTransferResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (await _repository.CheckOrder(saveTransferResource.MasterId, saveTransferResource.SequenceNumber)) { return(BadRequest("Siz emeliyyati artiq yerine yetirmisiniz!")); } var flowMaster = _mapper.Map <SaveTransferFlowResource, OsStFlowmaster>(saveTransferResource); flowMaster.CreatedDate = DateTime.Now; flowMaster.StatusId = 5;//In Progress var item = await _repository.UpdateItemForFlow(saveTransferResource.ItemCode, saveTransferResource.CompanyId); if (item == null) { return(BadRequest()); } flowMaster.CategoryId = item.CategoryId; flowMaster.SubCategoryId = item.SubCategoryId; _repository.AddMaster(flowMaster); await _unitOfWork.CompleteAsync(); var flowLine = _mapper.Map <SaveTransferFlowResource, OsStFlowlines>(saveTransferResource); flowLine.MasterId = flowMaster.Id; flowLine.ExecutedDate = DateTime.Now; _repository.AddLine(flowLine); await _unitOfWork.CompleteAsync(); if (saveTransferResource.FlowTypeId == 2 && saveTransferResource.SequenceNumber == 1)// b.m transfer kecenden sonra t.m mail getmesi { MailService.MailSender(_appSettings.CommercialMarketingMail, "https://onsale.veyseloglu.az:4443/transfer/" + flowLine.MasterId, flowLine.MasterId.ToString()); } else if (saveTransferResource.FlowTypeId == 3 && saveTransferResource.SequenceNumber == 1)//b.m qaytarma kecibse t mail getmesi { MailService.MailSender(_appSettings.OutfitMail, "https://onsale.veyseloglu.az:4443/transfer/" + flowLine.MasterId, flowLine.MasterId.ToString()); } return(Ok(saveTransferResource)); }
public async Task <IActionResult> CreateOrderFlow([FromBody] SaveOrderFlowResource saveOrderResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (await _repository.CheckOrder(saveOrderResource.MasterId, saveOrderResource.SequenceNumber)) { return(BadRequest("Siz emeliyyati artiq yerine yetirmisiniz!")); } var flowMaster = _mapper.Map <SaveOrderFlowResource, OsStFlowmaster>(saveOrderResource); flowMaster.CreatedDate = DateTime.Now; flowMaster.StatusId = 5;//In Progress if (flowMaster.SubCategoryId == 0) { flowMaster.SubCategoryId = null; } _repository.AddMaster(flowMaster); await _unitOfWork.CompleteAsync(); var flowLine = _mapper.Map <SaveOrderFlowResource, OsStFlowlines>(saveOrderResource); flowLine.MasterId = flowMaster.Id; flowLine.ExecutedDate = DateTime.Now; _repository.AddLine(flowLine); await _unitOfWork.CompleteAsync(); if (saveOrderResource.SequenceNumber == 1)// ticari marketiqe mail(b.m sifaris kecibse) { MailService.MailSender(_appSettings.CommercialMarketingMail, "https://onsale.veyseloglu.az:4443/order/" + flowLine.MasterId, flowLine.MasterId.ToString()); } else if (saveOrderResource.SequenceNumber == 2)// marketinqe mail (t.m sifaris kecibse) { MailService.MailSender(_appSettings.MarketingMail, "https://onsale.veyseloglu.az:4443/order/" + flowLine.MasterId, flowLine.MasterId.ToString()); } return(Ok(saveOrderResource)); }