public async Task <IActionResult> Post([FromBody] TypeStandardTime nTypeStandardTime)
        {
            if (nTypeStandardTime != null)
            {
                nTypeStandardTime.CreateDate = DateTime.Now;
                nTypeStandardTime.Creator    = nTypeStandardTime.Creator ?? "Someone";

                if (nTypeStandardTime.StandardTimes != null)
                {
                    foreach (var nStandard in nTypeStandardTime.StandardTimes)
                    {
                        nStandard.CreateDate = nTypeStandardTime.CreateDate;
                        nStandard.Creator    = nTypeStandardTime.Creator;
                    }
                }

                return(new JsonResult(await this.repository.AddAsync(nTypeStandardTime), this.DefaultJsonSettings));
            }
            return(NotFound(new { Error = "Type Standard Time not found." }));
        }
        public async Task <IActionResult> PutByNumber(int key, [FromBody] TypeStandardTime uTypeStandardTime)
        {
            if (uTypeStandardTime != null)
            {
                uTypeStandardTime.ModifyDate = DateTime.Now;
                uTypeStandardTime.Modifyer   = uTypeStandardTime.Modifyer ?? "Someone";

                if (uTypeStandardTime.StandardTimes != null)
                {
                    foreach (var standard in uTypeStandardTime.StandardTimes)
                    {
                        if (standard.StandardTimeId > 0)
                        {
                            standard.ModifyDate = uTypeStandardTime.ModifyDate;
                            standard.Modifyer   = uTypeStandardTime.Modifyer;
                        }
                        else
                        {
                            standard.CreateDate = uTypeStandardTime.ModifyDate;
                            standard.Creator    = uTypeStandardTime.Modifyer;
                        }
                    }
                }

                // update Master not update Detail it need to update Detail directly
                var updateComplate = await this.repository.UpdateAsync(uTypeStandardTime, key);

                if (updateComplate != null)
                {
                    // filter
                    Expression <Func <StandardTime, bool> > condition = m => m.StandardTimeId == key;
                    var dbStandards = await this.repositoryStandard.FindAllAsync(condition);

                    //Remove Jo if edit remove it
                    foreach (var dbStandard in dbStandards)
                    {
                        if (!uTypeStandardTime.StandardTimes.Any(x => x.StandardTimeId == dbStandard.StandardTimeId))
                        {
                            await this.repositoryStandard.DeleteAsync(dbStandard.StandardTimeId);
                        }
                    }
                    //Update JobCardDetail or New JobCardDetail
                    foreach (var uStandard in uTypeStandardTime.StandardTimes)
                    {
                        if (uStandard.StandardTimeId > 0)
                        {
                            await this.repositoryStandard.UpdateAsync(uStandard, uStandard.StandardTimeId);
                        }
                        else
                        {
                            if (uStandard.StandardTimeId < 1)
                            {
                                uStandard.TypeStandardTimeId = uTypeStandardTime.TypeStandardTimeId;
                            }

                            await this.repositoryStandard.AddAsync(uStandard);
                        }
                    }
                }
                return(new JsonResult(updateComplate, this.DefaultJsonSettings));

                //return new JsonResult(await this.repository.UpdateAsync(uTypeStandardTime, key), this.DefaultJsonSettings);
            }
            return(NotFound(new { Error = "Type Standard Time not found." }));
        }