Exemple #1
0
        public Fault AddFault(int OwnerID, int WorkerID, int RoomID, int FaultType, string Info, string base64)
        {
            string        imgRef = uploadImg(base64);
            Fault         fault  = null;
            List <string> temp   = new List <string>();

            if (imgRef != "")
            {
                temp.Add(imgRef);
            }
            var faultsResults = Dal.AddFault(OwnerID, WorkerID, RoomID, FaultType, Info, imgRef);

            if (faultsResults != null)
            {
                fault = new Fault
                {
                    Owner = new User
                    {
                        UserId = int.Parse(faultsResults.Rows[0]["ownerID"].ToString())
                    },
                    Worker = new User
                    {
                        UserId = int.Parse(faultsResults.Rows[0]["workerID"].ToString())
                    },
                    FaultId       = int.Parse(faultsResults.Rows[0]["faultID"].ToString()),
                    FaultTypeId   = int.Parse(faultsResults.Rows[0]["faultType"].ToString()),
                    FaultName     = faultsResults.Rows[0]["faultName"].ToString(),
                    FaultStatus   = int.Parse(faultsResults.Rows[0]["faultStatus"].ToString()),
                    Info          = faultsResults.Rows[0]["info"].ToString(),
                    OpenDate      = DateTime.Parse(faultsResults.Rows[0]["openDate"].ToString()),
                    FaultPictures = temp,
                };
                if (faultsResults.Rows[0]["closeDate"].ToString() != "")
                {
                    fault.CloseDate = DateTime.Parse(faultsResults.Rows[0]["closeDate"].ToString());
                }
            }

            return(fault);
        }