Ejemplo n.º 1
0
        private void AddWarehouse(ref OperationResult pobjOperationResult, List <nodeorganizationlocationwarehouseprofileDto> pobjWarehouseList, List <string> ClientSession)
        {
            try
            {
                SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();

                nodeorganizationlocationwarehouseprofile objnodeorganizationlocationwarehouseprofile = null;

                // Grabar almacén
                foreach (var item in pobjWarehouseList)
                {
                    var objEntitySource = (from a in dbContext.nodeorganizationlocationwarehouseprofile
                                           where a.i_NodeId == item.i_NodeId &&
                                           a.v_OrganizationId == item.v_OrganizationId &&
                                           a.v_LocationId == item.v_LocationId &&
                                           a.v_WarehouseId == item.v_WarehouseId
                                           select a).FirstOrDefault();

                    if (objEntitySource != null)
                    {
                        objEntitySource.d_UpdateDate   = DateTime.Now;
                        objEntitySource.i_UpdateUserId = Int32.Parse(ClientSession[2]);
                        objEntitySource.i_IsDeleted    = 0;

                        // Guardar los cambios
                        dbContext.SaveChanges();
                    }
                    else
                    {
                        objnodeorganizationlocationwarehouseprofile = nodeorganizationlocationwarehouseprofileAssembler.ToEntity(item);
                        objnodeorganizationlocationwarehouseprofile.d_InsertDate   = DateTime.Now;
                        objnodeorganizationlocationwarehouseprofile.i_InsertUserId = int.Parse(ClientSession[2]);
                        objnodeorganizationlocationwarehouseprofile.i_IsDeleted    = 0;

                        dbContext.AddTonodeorganizationlocationwarehouseprofile(objnodeorganizationlocationwarehouseprofile);
                        dbContext.SaveChanges();
                    }
                }

                pobjOperationResult.Success = 1;
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "", "", Success.Ok, null);
                return;
            }
            catch (Exception ex)
            {
                pobjOperationResult.Success          = 0;
                pobjOperationResult.ExceptionMessage = Common.Utils.ExceptionFormatter(ex);
                // Llenar entidad Log
                LogBL.SaveLog(ClientSession[0], ClientSession[1], ClientSession[2], LogEventType.CREACION, "", "", Success.Failed, pobjOperationResult.ExceptionMessage);
                return;
            }
        }