예제 #1
0
        public RequestResult <SpecificInformationModel> InsUpd(SpecificInformationModel model)
        {
            RequestResult <SpecificInformationModel> ER = new RequestResult <SpecificInformationModel>();

            using (var db = new EGULFEntities())
            {
                ObjectParameter Id = new ObjectParameter("MatchableId", typeof(int?));
                Id.Value = model.MatchableId;

                ER = db.sp_InsUpdSpecificInfo(Id, model.BHP, model.SubtypeId, model.BollardPullAhead,
                                              model.BollardPullAstern, model.NumberPassenger, model.AirCondition, model.MessRoom,
                                              model.ControlRoom, model.ConferenceRoom, model.Gymnasium, model.SwimingPool,
                                              model.Office, model.Hospital, model.CargoCapacity, model.PumpRates, model.Type,
                                              model.BollardPull, model.TankCapacity, model.DischargeRate, model.PemexCheck,
                                              model.DeckStrenght)
                     .Select(x => new RequestResult <SpecificInformationModel>()
                {
                    Status  = (bool)x.IsError ? Status.Error : Status.Success,
                    Message = x.Message
                }).FirstOrDefault();

                if (ER.Status == Status.Success)
                {
                    model.MatchableId = Convert.ToInt32(Id.Value.ToString());
                }

                return(ER);
            }
        }
예제 #2
0
 public VesselViewModel()
 {
     Vessel             = new VesselModel();
     VesselSpecificInfo = new VesselSpecificInfoModel();
     SpecificInfo       = new SpecificInformationModel();
     VesselCost         = new VesselCostModel();
 }
        public RequestResult <SpecificInformationModel> InsUpd(SpecificInformationModel model)
        {
            SpecificInformationDA specificInformationDA   = new SpecificInformationDA();
            RequestResult <SpecificInformationModel> resp = new RequestResult <SpecificInformationModel>()
            {
                Status = Status.Success
            };

            return(specificInformationDA.InsUpd(model));
        }
예제 #4
0
        public SpecificInformationModel GetSpecificInfoExtra(int referenceId)
        {
            SpecificInformationServices specificInformationServices = new SpecificInformationServices();
            CabinSpecificationServices  cabinSpecificationServices  = new CabinSpecificationServices();

            SpecificInformationModel       resp      = specificInformationServices.GetByReferenceId(referenceId, SpecificInformationModel.VESSEL_TYPE);
            List <CabinSpecificationModel> lstCabins = cabinSpecificationServices.GetByReferenceId(referenceId, SpecificInformationModel.VESSEL_TYPE);

            CabinSpecificationModel c1 = lstCabins.Where(c => c.CabinType == CabinSpecificationModel.SINGLE_BERTH).FirstOrDefault() ?? new CabinSpecificationModel();
            CabinSpecificationModel c2 = lstCabins.Where(c => c.CabinType == CabinSpecificationModel.DOUBLE_BERTH).FirstOrDefault() ?? new CabinSpecificationModel();
            CabinSpecificationModel c3 = lstCabins.Where(c => c.CabinType == CabinSpecificationModel.FOUR_BERTH).FirstOrDefault() ?? new CabinSpecificationModel();

            resp.SingleBerth = c1.CabinQuantity;
            resp.DoubleBerth = c2.CabinQuantity;
            resp.FourBerth   = c3.CabinQuantity;
            return(resp);
        }
예제 #5
0
        public RequestResult <object> SaveProject(ProjectModel parameters)
        {
            TransactionOptions scopeOptions = new TransactionOptions();

            //scopeOptions.IsolationLevel = IsolationLevel.ReadCommitted;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions))
            {
                try
                {
                    //here we save basic project info
                    var respSaveProjectBasicInfo = InsUpdProjectInfo(parameters);
                    if (respSaveProjectBasicInfo.Status == Status.Success)
                    {
                        SystemVariableServices SystemVariableServ = new SystemVariableServices();
                        Int16 TypeProject = Convert.ToInt16(SystemVariableServ.GetSystemVariableValue("TypeProject"));

                        var dataProjectBasicInfo = (ProjectModel)respSaveProjectBasicInfo.Data;
                        parameters.ProjectId = dataProjectBasicInfo.ProjectId;

                        //we save specific info
                        SpecificInformationServices SpecificInfoServ  = new SpecificInformationServices();
                        SpecificInformationModel    SpecificInfoModel = parameters;
                        SpecificInfoModel.MatchableId = parameters.ProjectId;
                        SpecificInfoModel.Type        = TypeProject;
                        var respSaveProjectSpecificInfo = SpecificInfoServ.InsUpd(SpecificInfoModel);
                        if (respSaveProjectSpecificInfo.Status == Status.Success)
                        {
                            //we validate project category and only save cabin specifications if project category is personnel transportation
                            ProjectTypeServices ProjectTypeServ    = new ProjectTypeServices();
                            ProjectTypeModel    ProjectType        = ProjectTypeServ.GetById(parameters.ProjectTypeId);
                            string CategoryPersonnelTransportation = SystemVariableServ.GetSystemVariableValue("CategoryPersonnelTransportation");
                            if (ProjectType.Category == CategoryPersonnelTransportation)
                            {
                                ////at the end we save cabin specifications
                                //CabinSpecificationServices CabinSpecificationServ = new CabinSpecificationServices();
                                //foreach (var item in parameters.CabinSpecification.ToList())
                                //{
                                //    item.ReferenceId = parameters.ProjectId;
                                //    item.Type = TypeProject;
                                //    var respSaveCabinSpecification = CabinSpecificationServ.InsUpd(item);
                                //    if (respSaveCabinSpecification.Status == Status.Error)
                                //        throw new Exception(respSaveCabinSpecification.Message);
                                //}
                            }

                            ts.Complete();
                            return(new RequestResult <object>()
                            {
                                Status = Status.Success, Data = parameters
                            });
                        }
                        else
                        {
                            throw new Exception(respSaveProjectSpecificInfo.Message);
                        }
                    }
                    else
                    {
                        //return respSaveProjectBasicInfo;
                        throw new Exception(respSaveProjectBasicInfo.Message);
                    }
                }
                catch (Exception ex)
                {
                    ts.Dispose();
                    return(new RequestResult <object>()
                    {
                        Status = Status.Error, Message = ex.Message
                    });
                }
            }
        }
예제 #6
0
        public RequestResult <VesselModel> InsUpdComplete(VesselModel vessel,
                                                          VesselSpecificInfoModel vesselSpecificInfo,
                                                          SpecificInformationModel specificInfo,
                                                          VesselCostModel vesselCost)
        {
            RequestResult <VesselModel> resp = new RequestResult <VesselModel>()
            {
                Status = Status.Success
            };
            SpecificInformationServices specificInfoServices       = new SpecificInformationServices();
            CabinSpecificationServices  cabinSpecificationServices = new CabinSpecificationServices();
            RegionServices     regionServices = new RegionServices();
            PortServices       portServices   = new PortServices();
            TransactionOptions scopeOptions   = new TransactionOptions();

            //scopeOptions.IsolationLevel = IsolationLevel.ReadCommitted;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions))
            {
                try
                {
                    //Ciclo para ir a buscar diferentes puntos en el mapa, en caso de que el q se me asigne de forma aleatoria, se encuentre ya en BD
                    int valLocation = 2;
                    int test        = 1;
                    int cont        = 0;
                    while (valLocation > test && cont <= 100)
                    {
                        //Si se va a insertar, le agregamos un punto en el mapa
                        if (vessel.VesselId == null)
                        {
                            test = 0;
                            PortModel port = portServices.GetById((int)vessel.HomePort.PortId);
                            vessel.Location = regionServices.GetLocation(port.Region.RegionId);
                        }
                        else    //De lo contrario verificamos si ha cambiado su puerto, si cambió le asignamos una nueva locación
                        {
                            test = 1;
                            int?RegionIdAct = portServices.GetById((int)vessel.HomePort.PortId).Region.RegionId;
                            int?RegionIdAnt = GetById((int)vessel.VesselId).HomePort.Region.RegionId;
                            if (RegionIdAnt != RegionIdAct)
                            {
                                vessel.Location = regionServices.GetLocation(RegionIdAct);
                            }
                        }

                        //Verificamos si existe otro Barco en el mismo punto
                        if (vessel.Location.Lat == 0)
                        {
                            test = valLocation;
                        }
                        else
                        {
                            valLocation =
                                Get(new VesselModel()
                            {
                                Location = new LatLng()
                                {
                                    Lat = vessel.Location.Lat,
                                    Lng = vessel.Location.Lng
                                }
                            }).Count();
                        }
                        cont++;
                    }
                    if (cont == 100)
                    {
                        throw new Exception("Se ha alcanzado el número de barcos permitidos para una región");
                    }

                    RequestResult <VesselModel> res1 = InsUpd(vessel);
                    if (res1.Status != Status.Success)
                    {
                        throw new Exception(res1.Message);
                    }

                    vesselSpecificInfo.VesselId       = res1.Data.VesselId;
                    vesselSpecificInfo.UserModifiedId = vessel.UserModifiedId;
                    RequestResult <VesselSpecificInfoModel> res2 = InsUpdSpecificInfo(vesselSpecificInfo);
                    if (res2.Status != Status.Success)
                    {
                        throw new Exception(res2.Message);
                    }

                    specificInfo.MatchableId = res1.Data.VesselId;
                    specificInfo.Type        = SpecificInformationModel.VESSEL_TYPE;
                    RequestResult <SpecificInformationModel> res3 = specificInfoServices.InsUpd(specificInfo);
                    if (res3.Status != Status.Success)
                    {
                        throw new Exception(res3.Message);
                    }

                    List <CabinSpecificationModel>          lstCabins = specificInfo.GetCabinSpecificationList(CabinSpecificationModel.VESSEL_TYPE);
                    RequestResult <CabinSpecificationModel> respC;
                    foreach (CabinSpecificationModel cabin in lstCabins)
                    {
                        respC = cabinSpecificationServices.InsUpd(cabin);
                        if (respC.Status != Status.Success)
                        {
                            throw new Exception(respC.Message);
                        }
                    }

                    vesselCost.VesselId = res1.Data.VesselId;
                    RequestResult <VesselCostModel> res4 = InsUpdCost(vesselCost);
                    if (res4.Status != Status.Success)
                    {
                        throw new Exception(res4.Message);
                    }

                    resp = res1;
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    resp.Status  = Status.Error;
                    resp.Message = ex.Message;
                    ts.Dispose();
                    throw new Exception(ex.Message);
                }
            }

            return(resp);
        }