public static ResponseModel AddWorkCenterRoutingFile(WorkCenterRoutingFileModel m, ref int _newID)
 {
     ACTION = "AddWorkCenterRoutingFile(WorkCenterRoutingFileModel)";
     try
     {
         _newID = 0;
         ResponseModel res = WorkCenterRoutingFileDAL.AddWorkCenterRoutingFile(m, ref _newID);
         return(new ResponseModel()
         {
             Action = ACTION,
             Source = SOURCE,
             Message = res.Message,
             Status = res.Status
         });
     }
     catch (Exception ex)
     {
         return(new ResponseModel()
         {
             Action = ACTION,
             Source = SOURCE,
             Message = ex.Message,
             Status = false
         });
     }
 }
        internal static USR_TMMA_WORKCENTER_ROUTING_FILE Mapping(WorkCenterRoutingFileModel o)
        {
            try
            {
                if (o != null)
                {
                    return(new USR_TMMA_WORKCENTER_ROUTING_FILE()
                    {
                        WorkCenterRoutingFileID = o.WorkCenterRoutingFileID,
                        RecObjectName = o.RecObjectName,
                        UserSAP = o.UserSAP,
                        WorkCenterRoutingFilePath = o.WorkCenterRoutingFilePath,
                        WorkCenterRoutingFileVersion = o.WorkCenterRoutingFileVersion,
                        WorkCenterRoutingFileStatus = o.WorkCenterRoutingFileStatus,
                        ProductsTypeID = o.ProductsTypeID,
                        IsActive = o.IsActive ? 1 : 0,
                        CreatedBy = o.CreatedBy,
                        CreatedDate = o.CreatedDate,
                        UpdatedBy = o.UpdatedBy,
                        UpdatedDate = o.UpdatedDate,
                        ValidDate = o.ValidDate
                    });
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static WorkCenterRoutingFileModel GetWorkCenterRoutingFile(int workCenterRoutingFileID)
        {
            ACTION = "GetWorkCenterRoutingFile(workCenterRoutingFileID)";

            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    USR_TMMA_WORKCENTER_ROUTING_FILE obj = context.USR_TMMA_WORKCENTER_ROUTING_FILE.Where(o => o.WorkCenterRoutingFileID == workCenterRoutingFileID).FirstOrDefault();
                    WorkCenterRoutingFileModel       m   = Mapping(obj);
                    return(m);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static WorkCenterRoutingFileModel GetWorkCenterRoutingFileLastVersion()
        {
            ACTION = "GetWorkCenterRoutingFileLastVersion()";
            try
            {
                using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                {
                    List <USR_TMMA_WORKCENTER_ROUTING_FILE> list = context.USR_TMMA_WORKCENTER_ROUTING_FILE.ToList();
                    var o = list.Count > 0 ? list.Last() : null;
                    WorkCenterRoutingFileModel m = Mapping(o);

                    return(m);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
 public ResponseModel AddWorkCenterRoutingFile(WorkCenterRoutingFileModel m, ref int _newID)
 {
     return(WorkCenterRoutingFileBLL.AddWorkCenterRoutingFile(m, ref _newID));
 }
        public static ResponseModel AddWorkCenterRoutingFile(WorkCenterRoutingFileModel m, ref int _newID)
        {
            string action = "AddWorkCenterRoutingFile(WorkCenterRoutingFileModel, out _newID)";

            _newID = 0;
            try
            {
                if (m != null)
                {
                    using (UTMMABCDBEntities context = new UTMMABCDBEntities())
                    {
                        USR_TMMA_WORKCENTER_ROUTING_FILE _obj = Mapping(m);

                        context.USR_TMMA_WORKCENTER_ROUTING_FILE.Add(_obj);

                        if (context.SaveChanges() > 0)
                        {
                            _newID = _obj.WorkCenterRoutingFileID;

                            return(new ResponseModel()
                            {
                                Source = SOURCE,
                                Action = action,
                                Status = true,
                                Message = "Success"
                            });
                        }

                        return(new ResponseModel()
                        {
                            Source = SOURCE,
                            Action = action,
                            Status = false,
                            Message = "Fail"
                        });
                    }
                }

                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = "Null"
                });
            }
            catch (DbEntityValidationException ex)
            {
                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = ex.Message,
                    StackTrace = ex.StackTrace
                });
            }
            catch (Exception ex)
            {
                return(new ResponseModel()
                {
                    Source = SOURCE,
                    Action = action,
                    Status = false,
                    Message = ex.Message,
                    StackTrace = ex.StackTrace
                });
            }
        }