public CommonResponse AddUpdateChildFgPartNo(addChildfgPartNoDet data)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var check = db.UnitworkccsTblchildfgpartno.Where(m => m.ChildFgpartId == data.childFgpartId && m.IsDeleted == 0).FirstOrDefault();
                if (check == null)
                {
                    UnitworkccsTblchildfgpartno UnitworkccsTblchildfgpartnodet = new UnitworkccsTblchildfgpartno();
                    UnitworkccsTblchildfgpartnodet.ChildFgpartId   = data.childFgpartId;
                    UnitworkccsTblchildfgpartnodet.ChildFgPartNo   = data.fgPartNo;
                    UnitworkccsTblchildfgpartnodet.FgPartNo        = data.fgPartNo;
                    UnitworkccsTblchildfgpartnodet.ChildPartNoDesc = data.childPartNoDesc;
                    UnitworkccsTblchildfgpartnodet.FgPartDesc      = db.UnitworkccsTblfgandcellallocation.Where(m => m.PartNo == data.fgPartNo).Select(m => m.PartName).FirstOrDefault();
                    UnitworkccsTblchildfgpartnodet.IsDeleted       = 0;
                    UnitworkccsTblchildfgpartnodet.CreatedBy       = 1;
                    UnitworkccsTblchildfgpartnodet.CreatedOn       = DateTime.Now;
                    db.UnitworkccsTblchildfgpartno.Add(UnitworkccsTblchildfgpartnodet);
                    db.SaveChanges();

                    obj.isStatus = true;
                    obj.response = ResourceResponse.AddedSuccessMessage;
                }
                else
                {
                    //check.ChildFgpartId = data.ChildFgpartId;
                    check.ChildFgPartNo = data.childFgPartNo;
                    check.FgPartNo      = data.fgPartNo;
                    check.FgPartDesc    = db.UnitworkccsTblfgandcellallocation.Where(m => m.PartNo == data.fgPartNo).Select(m => m.PartName).FirstOrDefault();

                    check.ChildPartNoDesc = data.childPartNoDesc;
                    check.ModifiedBy      = 2;
                    check.ModifiedOn      = DateTime.Now;
                    db.SaveChanges();
                    obj.isStatus = true;
                    obj.response = ResourceResponse.UpdatedSuccessMessage;
                }
            }
            catch (Exception e)
            {
                log.Error(e); if (e.InnerException != null)
                {
                    log.Error(e.InnerException.ToString());
                }
                obj.isStatus = false;
                obj.response = ResourceResponse.FailureMessage;
            }
            return(obj);
        }
Пример #2
0
        public async Task <IActionResult> AddUpdateChildFgPartNo([FromBody] addChildfgPartNoDet data)
        {
            CommonResponse response = allChildFgPartMasters.AddUpdateChildFgPartNo(data);

            return(Ok(response));
        }