コード例 #1
0
        public async Task <IActionResult> AddAndEditToolAndSocketDetails(TblToolAndSocketDetailsCustom data)
        {
            //calling DepartmentDAL busines layer
            CommonResponse response = toolLife.AddAndEditToolAndSocketDetails(data);

            return(Ok(response));
        }
コード例 #2
0
        /// <summary>
        /// Redirect The Page
        /// </summary>
        /// <param name="HostName"></param>
        /// <param name="IpAddress"></param>
        /// <returns></returns>
        public CommonResponse AddAndEditToolAndSocketDetails(TblToolAndSocketDetailsCustom data)
        {
            CommonResponse obj = new CommonResponse();

            try
            {
                var check = db.UnitworkccsTbltoolandsocketdetails.Where(m => m.MachineId == data.machineId && m.SocketNo == data.socketNo && m.IsDeleted == 0).FirstOrDefault();
                if (check == null)
                {
                    var item = db2.TblIssuedReceived.Where(m => m.BarCodeNo == data.toolNumber && m.MachineId == data.machineId).FirstOrDefault();
                    if (item != null)
                    {
                        var toolDetails = db2.TblTools.Where(m => m.ToolName.Trim().Contains(item.ToolName.Trim())).FirstOrDefault();
                        if (toolDetails != null)
                        {
                            int stdToolLife = Convert.ToInt32(toolDetails.StandardToolLife);
                            UnitworkccsTbltoolandsocketdetails tblToolAndSocket = new UnitworkccsTbltoolandsocketdetails();
                            tblToolAndSocket.Qrcode               = data.toolNumber;
                            tblToolAndSocket.ToolNumber           = item.ToolName.Trim();
                            tblToolAndSocket.SocketNo             = data.socketNo;
                            tblToolAndSocket.MachineId            = data.machineId;
                            tblToolAndSocket.StandardToolLife     = stdToolLife;
                            tblToolAndSocket.ActaulToolLife       = 0;
                            tblToolAndSocket.ToolInsertedDateTime = DateTime.Now;
                            tblToolAndSocket.CreatedOn            = DateTime.Now;
                            tblToolAndSocket.CreatedBy            = 1;
                            tblToolAndSocket.IsDeleted            = 0;
                            db.Add(tblToolAndSocket);
                            db.SaveChanges();
                        }
                    }

                    obj.isStatus = true;
                    obj.response = Resource.ResourceResponse.AddedSuccessMessage;
                }
            }
            catch (Exception e)
            {
                log.Error(e); if (e.InnerException != null)
                {
                    log.Error(e.InnerException.ToString());
                }
                obj.isStatus = false;
                obj.response = ResourceResponse.FailureMessage;
            }
            return(obj);
        }