Ejemplo n.º 1
0
        public bool ENT_Owner_Update(IEnumerable <ENT_Owner> items, string ModifiedBy)
        {
            string ENT_Owner_List             = string.Empty;
            string ENT_Owner_List_Serialized  = string.Empty;
            string ENT_Owner_Items_Serialized = string.Empty;

            string result = string.Empty;
            bool   flag   = true;

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_Owner item in items)
                {
                    ENT_Owner dbItem = model.DBSet_ENT_Owner.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        ENT_Owner_List   += "[" + item.ID + "] ";
                        item.ModifiedBy   = ModifiedBy;
                        item.ModifiedDate = Common.getUTCDate();
                        if (item.CreatedDate == DateTime.MinValue)
                        {
                            item.CreatedDate = dbItem.CreatedDate;
                        }
                        dbItem.IsSelected             = item.IsSelected;
                        dbItem.TagStr                 = item.TagStr;
                        dbItem.Address                = item.Address;
                        dbItem.Allocation_Strategy_ID = item.Allocation_Strategy_ID;
                        dbItem.Billing_Address        = item.Billing_Address;
                        dbItem.Billing_City           = item.Billing_City;
                        dbItem.Billing_District       = item.Billing_District;
                        dbItem.Billing_Email1         = item.Billing_Email1;
                        dbItem.Billing_Email2         = item.Billing_Email2;
                        dbItem.Billing_Fax1           = item.Billing_Fax1;
                        dbItem.Billing_Fax2           = item.Billing_Fax2;
                        dbItem.Billing_Phone1         = item.Billing_Phone1;
                        dbItem.Billing_Phone2         = item.Billing_Phone2;
                        dbItem.Carrier_ID             = item.Carrier_ID;
                        dbItem.Cartonization_ID       = item.Cartonization_ID;
                        dbItem.City                         = item.City;
                        dbItem.Company                      = item.Company;
                        dbItem.CreatedBy                    = item.CreatedBy;
                        dbItem.CreatedDate                  = item.CreatedDate;
                        dbItem.Customer_ID                  = item.Customer_ID;
                        dbItem.Cycle_Class_ID               = item.Cycle_Class_ID;
                        dbItem.District                     = item.District;
                        dbItem.Email1                       = item.Email1;
                        dbItem.Email2                       = item.Email2;
                        dbItem.Fax1                         = item.Fax1;
                        dbItem.Fax2                         = item.Fax2;
                        dbItem.ID                           = item.ID;
                        dbItem.IsDeleted                    = item.IsDeleted;
                        dbItem.ModifiedBy                   = item.ModifiedBy;
                        dbItem.ModifiedDate                 = item.ModifiedDate;
                        dbItem.Notes                        = item.Notes;
                        dbItem.Owner_Code                   = item.Owner_Code;
                        dbItem.Phone1                       = item.Phone1;
                        dbItem.Phone2                       = item.Phone2;
                        dbItem.Putaway_Strategy_ID          = item.Putaway_Strategy_ID;
                        dbItem.Receipt_Validation_Detail_ID = item.Receipt_Validation_Detail_ID;
                        dbItem.Rotation_Detail_By           = item.Rotation_Detail_By;
                        dbItem.Rotation_Detail_ID           = item.Rotation_Detail_ID;
                        dbItem.Supplier_ID                  = item.Supplier_ID;
                        dbItem.UDF_1                        = item.UDF_1;
                        dbItem.UDF_2                        = item.UDF_2;
                        dbItem.UDF_3                        = item.UDF_3;
                        dbItem.UDF_4                        = item.UDF_4;
                        dbItem.UDF_5                        = item.UDF_5;
                        dbItem.V_Cycle_Count_ID             = item.V_Cycle_Count_ID;


                        ENT_Owner_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        ENT_Owner_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(ENT_Owner_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + ENT_Owner_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Owner_Update: {1} - {2}", ModifiedBy, ENT_Owner_List, ENT_Owner_List_Serialized));
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public DataSourceResult ENT_Owner_Create(ENT_Owner item, string CreatedBy)
        {
            string ENT_Owner_List             = string.Empty;
            string ENT_Owner_List_Serialized  = string.Empty;
            string ENT_Owner_Items_Serialized = string.Empty;

            string           message = string.Empty;
            List <ENT_Owner> result  = new List <ENT_Owner>();

            try
            {
                WMS.Models.DBContext model = new DBContext();

                ENT_Owner dbItem = new ENT_Owner();

                item.CreatedBy                = item.ModifiedBy = CreatedBy;
                item.CreatedDate              = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected             = item.IsSelected;
                dbItem.TagStr                 = item.TagStr;
                dbItem.Address                = item.Address;
                dbItem.Allocation_Strategy_ID = item.Allocation_Strategy_ID;
                dbItem.Billing_Address        = item.Billing_Address;
                dbItem.Billing_City           = item.Billing_City;
                dbItem.Billing_District       = item.Billing_District;
                dbItem.Billing_Email1         = item.Billing_Email1;
                dbItem.Billing_Email2         = item.Billing_Email2;
                dbItem.Billing_Fax1           = item.Billing_Fax1;
                dbItem.Billing_Fax2           = item.Billing_Fax2;
                dbItem.Billing_Phone1         = item.Billing_Phone1;
                dbItem.Billing_Phone2         = item.Billing_Phone2;
                dbItem.Carrier_ID             = item.Carrier_ID;
                dbItem.Cartonization_ID       = item.Cartonization_ID;
                dbItem.City                         = item.City;
                dbItem.Company                      = item.Company;
                dbItem.CreatedBy                    = item.CreatedBy;
                dbItem.CreatedDate                  = item.CreatedDate;
                dbItem.Customer_ID                  = item.Customer_ID;
                dbItem.Cycle_Class_ID               = item.Cycle_Class_ID;
                dbItem.District                     = item.District;
                dbItem.Email1                       = item.Email1;
                dbItem.Email2                       = item.Email2;
                dbItem.Fax1                         = item.Fax1;
                dbItem.Fax2                         = item.Fax2;
                dbItem.ID                           = item.ID;
                dbItem.IsDeleted                    = item.IsDeleted;
                dbItem.ModifiedBy                   = item.ModifiedBy;
                dbItem.ModifiedDate                 = item.ModifiedDate;
                dbItem.Notes                        = item.Notes;
                dbItem.Owner_Code                   = item.Owner_Code;
                dbItem.Phone1                       = item.Phone1;
                dbItem.Phone2                       = item.Phone2;
                dbItem.Putaway_Strategy_ID          = item.Putaway_Strategy_ID;
                dbItem.Receipt_Validation_Detail_ID = item.Receipt_Validation_Detail_ID;
                dbItem.Rotation_Detail_By           = item.Rotation_Detail_By;
                dbItem.Rotation_Detail_ID           = item.Rotation_Detail_ID;
                dbItem.Supplier_ID                  = item.Supplier_ID;
                dbItem.UDF_1                        = item.UDF_1;
                dbItem.UDF_2                        = item.UDF_2;
                dbItem.UDF_3                        = item.UDF_3;
                dbItem.UDF_4                        = item.UDF_4;
                dbItem.UDF_5                        = item.UDF_5;
                dbItem.V_Cycle_Count_ID             = item.V_Cycle_Count_ID;
                ENT_Owner_Items_Serialized         += Common.SerializeObject(item);
                model.DBSet_ENT_Owner.Add(dbItem);
                Common.SaveChanges(model);

                item.ID         = dbItem.ID;
                ENT_Owner_List += "[" + item.ID + "] ";

                result.Add(item);
                ENT_Owner_List_Serialized += Common.SerializeObject(item);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(ENT_Owner_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + ENT_Owner_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Owner_Create: {1} - {2}", CreatedBy, ENT_Owner_List, ENT_Owner_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }