Esempio n. 1
0
        public virtual ActionResult Index()
        {
            AnmalanModel anmalan = TempData["anmalan"] as AnmalanModel;
            if (anmalan == null)
            {
                anmalan = new AnmalanModel();
                PrismaServiceClient client = new PrismaServiceClient();

                var request = new RequestMessageGetAllZones();
                var response = client.GetAllZones(request);
                anmalan.ZoneList = new List<Zone>(response.Zones);

                anmalan.BuildingList = new List<Building>();

                anmalan.FloorList = new List<Floor>();
                anmalan.RoomList = new List<Room>();

                var actions = client.GetAllWORequestActions();
                anmalan.ActionList = new List<ActionEntity>(actions);
                client.Close();

                anmalan.WRDescription = "";
            }

            TempData["anmalan"] = anmalan;
            return View(anmalan);
        }
Esempio n. 2
0
        public virtual ActionResult Index()
        {
            AnmalanModel anmalan = TempData["anmalan"] as AnmalanModel;

            if (anmalan == null)
            {
                anmalan = new AnmalanModel();
                PrismaServiceClient client = new PrismaServiceClient();

                var request  = new RequestMessageGetAllZones();
                var response = client.GetAllZones(request);
                anmalan.ZoneList = new List <Zone>(response.Zones);

                anmalan.BuildingList = new List <Building>();

                anmalan.FloorList = new List <Floor>();
                anmalan.RoomList  = new List <Room>();

                var actions = client.GetAllWORequestActions();
                anmalan.ActionList = new List <ActionEntity>(actions);
                client.Close();

                anmalan.WRDescription = "";
            }

            TempData["anmalan"] = anmalan;
            return(View(anmalan));
        }
Esempio n. 3
0
        public ResponseMessageGetAllZones GetAllZones(RequestMessageGetAllZones request)
        {
            //Create request
            ResponseMessageGetAllZones response = new ResponseMessageGetAllZones();

            response.Zones = new List <Zone>();

            //Log request
            var str = ObjectSerializer.SerializeObject(request);

            BasicLogger.Log.Info(str);

            //Validate request workflow
            ValidationResults validationResults = Validation.Validate(request);

            if (!validationResults.IsValid)
            {
                StringBuilder errorString = new StringBuilder();
                errorString.AppendLine(String.Format("The following {0} validation errors were detected:", validationResults.Count));

                foreach (Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResult item in validationResults)
                {
                    errorString.AppendLine(String.Format("Target:'{0}' Key:'{1}' Tag:'{2}' Message:'{3}'", item.Target, item.Key, item.Tag, item.Message));
                }

                BasicLogger.Log.Critical(errorString.ToString());

                response.Status = ResponseMessageBase.MessageStatus.FAILURE;
                response.Errors = new MessageErrorList();
                foreach (var validationResult in validationResults)
                {
                    //TODO skapa en constructor i MessageError som tar in ett validationresult objekt
                    response.Errors.Add(new MessageError
                    {
                        ErrorMessage = validationResult.Message,
                        ErrorNumber  = validationResult.Key,
                        Severity     = MessageError.ErrorSeverity.Error,
                        Type         = MessageError.ErrorType.ValidationError
                    });
                }

                return(response);
            }

            //TODO flytta till ett busineslayer
            //Execute get building zones workflow
            foreach (var item in dbPrisma.BLzone.ToList())
            {
                Zone zone = new Zone();
                zone.Description = item.descr;
                zone.ZoneCode    = item.blzone_code;

                response.Zones.Add(zone);
            }

            //Log response
            str = ObjectSerializer.SerializeObject(response);
            BasicLogger.Log.Info(str);

            return(response);
        }