public async Task <IActionResult> Post([FromBody] StandradTime nStandradTime) { if (nStandradTime != null) { nStandradTime = helpers.AddHourMethod(nStandradTime); nStandradTime.CreateDate = DateTime.Now; nStandradTime.Creator = nStandradTime.Creator ?? "Someone"; nStandradTime.LinkStandradTime = null; var complate = await this.repository.AddAsync(nStandradTime); if (complate != null && complate.LinkStandardTimeId.HasValue) { var update = await this.repository.GetAsync(complate.LinkStandardTimeId.Value); if (update != null) { update.LinkStandardTimeId = complate.StandradTimeId; await this.repository.UpdateAsync(update, update.StandradTimeId); } } return(new JsonResult(complate, this.DefaultJsonSettings)); } return(NotFound(new { Error = "Not found StandradTime data !!!" })); }
public async Task <IActionResult> Post([FromBody] ProjectMasterViewModel nProjectCodeMasterVM) { if (nProjectCodeMasterVM != null) { var nProjectCodeMaster = this.mapper.Map <ProjectMasterViewModel, ProjectCodeMaster>(nProjectCodeMasterVM); // add hour to DateTime to set Asia/Bangkok nProjectCodeMaster = helpers.AddHourMethod(nProjectCodeMaster); nProjectCodeMaster.CreateDate = DateTime.Now; nProjectCodeMaster.Creator = nProjectCodeMaster.Creator ?? "Someone"; var insertComplate = await this.repository.AddAsync(nProjectCodeMaster); if (insertComplate != null) { if (nProjectCodeMasterVM.ProjectSubs != null) { foreach (var nDetail in nProjectCodeMasterVM.ProjectSubs) { nDetail.CreateDate = nProjectCodeMaster.CreateDate; nDetail.Creator = nProjectCodeMaster.Creator; nDetail.ProjectCodeMasterId = insertComplate.ProjectCodeMasterId; nDetail.ProjectSubStatus = ProjectSubStatus.Use; await this.repositorySub.AddAsync(nDetail); } } } return(new JsonResult(insertComplate, this.DefaultJsonSettings)); } return(NotFound(new { Error = "ProjectMaster not found. " })); }
public async Task <IActionResult> Post([FromBody] JobCardMaster nJobCardMaster) { if (nJobCardMaster != null) { nJobCardMaster.JobCardMasterNo = await this.GeneratedCode(nJobCardMaster.ProjectCodeDetailId ?? 0, nJobCardMaster.TypeMachineId ?? 0); // add hour to DateTime to set Asia/Bangkok nJobCardMaster = helpers.AddHourMethod(nJobCardMaster); nJobCardMaster.JobCardMasterStatus = JobCardMasterStatus.Wait; nJobCardMaster.CreateDate = DateTime.Now; nJobCardMaster.Creator = nJobCardMaster.Creator ?? "Someone"; if (nJobCardMaster.JobCardDetails != null) { foreach (var nDetail in nJobCardMaster.JobCardDetails) { nDetail.JobCardDetailStatus = JobCardDetailStatus.Wait; nDetail.CreateDate = nJobCardMaster.CreateDate; nDetail.Creator = nJobCardMaster.Creator; // Insert UnitMeasure if (nDetail.UnitMeasureId < 1 && nDetail.UnitsMeasure != null) { nDetail.UnitsMeasure.CreateDate = nJobCardMaster.CreateDate; nDetail.UnitsMeasure.Creator = nJobCardMaster.Creator; } else { nDetail.UnitsMeasure = null; } // Insert CuttingPlan if (nDetail.CuttingPlanId < 1 && nDetail.CuttingPlan != null) { nDetail.CuttingPlan.CreateDate = nJobCardMaster.CreateDate; nDetail.CuttingPlan.Creator = nJobCardMaster.Creator; if (string.IsNullOrEmpty(nDetail?.CuttingPlan.MaterialSize)) { nDetail.CuttingPlan.MaterialSize = nDetail.Material; } if (nDetail?.CuttingPlan?.Quantity == null || nDetail?.CuttingPlan?.Quantity < 1) { nDetail.CuttingPlan.Quantity = nDetail.Quality; } } else { nDetail.CuttingPlan = null; } } } return(new JsonResult(await this.repository.AddAsync(nJobCardMaster), this.DefaultJsonSettings)); } return(NotFound(new { Error = "JobCardMaster not found. " })); }
public async Task <IActionResult> Post([FromBody] HolidayOverTime nHolidayOverTime) { if (nHolidayOverTime != null) { nHolidayOverTime = helpers.AddHourMethod(nHolidayOverTime); return(new JsonResult(await this.repository.AddAsync(nHolidayOverTime), this.DefaultJsonSettings)); } return(NotFound(new { Error = "Not found employee." })); }
public async Task <IActionResult> Post([FromBody] PaymentCostHistory nPaymentCostHistory) { if (nPaymentCostHistory != null) { nPaymentCostHistory = helpers.AddHourMethod(nPaymentCostHistory); nPaymentCostHistory.CreateDate = DateTime.Now; nPaymentCostHistory.Creator = nPaymentCostHistory.Creator ?? "Someone"; return(new JsonResult(await this.repository.AddAsync(nPaymentCostHistory), this.DefaultJsonSettings)); } return(NotFound(new { Error = "Not found PaymentCostHistory data !!!" })); }
public async Task <IActionResult> Post([FromBody] SurfaceType nSurfaceType) { if (nSurfaceType != null) { nSurfaceType = helpers.AddHourMethod(nSurfaceType); nSurfaceType.CreateDate = DateTime.Now; nSurfaceType.Creator = nSurfaceType.Creator ?? "Someone"; return(new JsonResult(await this.repository.AddAsync(nSurfaceType), this.DefaultJsonSettings)); } return(NotFound(new { Error = "Not found SurfaceType data !!!" })); }
public async Task <IActionResult> PutByNumber(int key, [FromBody] ColorItem uColorItem) { var Message = "Not found ColorItem data."; try { if (uColorItem != null) { // add hour to DateTime to set Asia/Bangkok uColorItem = helpers.AddHourMethod(uColorItem); uColorItem.ModifyDate = DateTime.Now; uColorItem.Modifyer = uColorItem.Modifyer ?? "Someone"; var UpdateData = await this.repository.UpdateAsync(uColorItem, key); if (UpdateData != null) { return(new JsonResult(UpdateData, this.DefaultJsonSettings)); } } } catch (Exception ex) { Message = $"Has error {ex.ToString()}"; } return(NotFound(new { Error = Message })); }
public async Task <IActionResult> Post([FromBody] RequirePaintingMaster nRequirePaintingMaster) { if (nRequirePaintingMaster != null) { nRequirePaintingMaster = helpers.AddHourMethod(nRequirePaintingMaster); nRequirePaintingMaster.CreateDate = DateTime.Now; nRequirePaintingMaster.Creator = nRequirePaintingMaster.Creator ?? "Someone"; nRequirePaintingMaster.RequireNo = await this.GeneratedCode(nRequirePaintingMaster.ProjectCodeSubId ?? -1); if (nRequirePaintingMaster.RequirePaintingLists != null) { nRequirePaintingMaster.RequirePaintingLists = null; } return(new JsonResult(await this.repository.AddAsync(nRequirePaintingMaster), this.DefaultJsonSettings)); } return(NotFound(new { Error = "Not found RequirePaintingMaster data !!!" })); }
public async Task <IActionResult> Post([FromBody] ProjectCodeSub nProjectCodeSub) { if (nProjectCodeSub != null) { var temp = await this.repository.GetAllAsQueryable() .Where(x => x.ProjectCodeMasterId == nProjectCodeSub.ProjectCodeMasterId && x.Code.ToLower().Trim().Equals(nProjectCodeSub.Code.ToLower().Trim())) .FirstOrDefaultAsync(); if (temp == null) { nProjectCodeSub = helpers.AddHourMethod(nProjectCodeSub); nProjectCodeSub.CreateDate = DateTime.Now; nProjectCodeSub.Creator = nProjectCodeSub.Creator ?? "Someone"; // Trim nProjectCodeSub.Code = nProjectCodeSub.Code.Trim(); if (!nProjectCodeSub.ProjectSubStatus.HasValue || nProjectCodeSub.ProjectSubStatus == null) { nProjectCodeSub.ProjectSubStatus = ProjectSubStatus.Use; } //if (nProjectCodeSub.ProjectCodeMaster != null) // nProjectCodeSub.ProjectCodeMaster = null; if (nProjectCodeSub.ProjectSubParent != null) { nProjectCodeSub.ProjectSubParent = null; } return(new JsonResult(await this.repository.AddAsync(nProjectCodeSub), this.DefaultJsonSettings)); } else { return(new JsonResult(temp, this.DefaultJsonSettings)); } } return(NotFound(new { Error = "Not found ProjectCodeSub data !!!" })); }
public async Task <IActionResult> Post([FromBody] ProjectCodeMaster nProjectCodeMaster) { if (nProjectCodeMaster != null) { // add hour to DateTime to set Asia/Bangkok nProjectCodeMaster = helpers.AddHourMethod(nProjectCodeMaster); nProjectCodeMaster.CreateDate = DateTime.Now; nProjectCodeMaster.Creator = nProjectCodeMaster.Creator ?? "Someone"; if (nProjectCodeMaster.ProjectCodeDetails != null) { foreach (var nDetail in nProjectCodeMaster.ProjectCodeDetails) { nDetail.CreateDate = nProjectCodeMaster.CreateDate; nDetail.Creator = nProjectCodeMaster.Creator; } } return(new JsonResult(await this.repository.AddAsync(nProjectCodeMaster), this.DefaultJsonSettings)); } return(NotFound(new { Error = "ProjectMaster not found. " })); }