public ActionResult UpdateServiceOrderPartLines(string uniqueId, string serviceOrderNo, string transactionType, string technicinanNo, string quantity, string specialityCode, string failureCode, string lineProperty, string serviceOrderRelation, string description, string serviceComments, string itemNumber, string site, string wareHouse, string transSerialCodeNo, string colorId, string sizeId, string configId, string locationId)
        {
            string userName = null;

            bool isSuccess = false;

            userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {
                SerivceOrderPartLine serviceOrderPartLine = new SerivceOrderPartLine();
                isSuccess = serviceOrderPartLine.UpdateServiceOrderPartLines(uniqueId, serviceOrderNo, transactionType, technicinanNo, quantity, specialityCode, failureCode, lineProperty, serviceOrderRelation, description, serviceComments, itemNumber, site, wareHouse, transSerialCodeNo, colorId = "", sizeId = "", configId = "", locationId, userName);
                if (isSuccess)
                {
                    ViewData["ServiceOrderPartLines"] = GetServiceOrderPartLinesByServiceOrderID(serviceOrderNo);
                }
                else
                {
                    throw new Exception("Service Order Part Lines updation failed");
                }

                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();

                if (!isSuccess)
                {
                    ExceptionLog.LogException(ex, userName);
                    throw ex;
                }
            }
            return(View("ServiceOrderPartLinesView"));
        }
Example #2
0
        public HttpResponseMessage CreateNewClient([FromBody] ClientServiceModel clientServiceModel)
        {
            try
            {
                Client client = clientServiceModel.client;

                client.DateLastUpdated = DateTime.Now;
                if (client.ParentID == null)
                {
                    client.ParentID     = 0;
                    client.DivisionName = client.ClientName;
                }
                context.Clients.InsertOnSubmit(client);
                context.SubmitChanges();

                foreach (int clientService in clientServiceModel.clientServices)
                {
                    context.Client_Services.InsertOnSubmit(new Client_Service {
                        ClientID = client.ClientID, ServiceID = clientService
                    });
                }

                context.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, client.ClientID));
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #3
0
        public HttpResponseMessage GetClaimFileDataForUser(string Token)
        {
            try
            {
                using (context = new OrgSys2017DataContext())
                {
                    var filters      = context.GetFilteredData(Token, "Document")?.ToList();
                    var userRoleName = context.GetUserRole(Token).FirstOrDefault().RoleName;
                    var qservice     = new QueryService("Claim_Documents", "Document", Token);

                    if (filters == null && userRoleName != "OSIUser")
                    {
                        return(Request.CreateResponse(HttpStatusCode.Forbidden));
                    }

                    var dataView = context.GetPortalPortalDataView(Token, "Document").ToList();
                    var query    = qservice.BuildQuery(dataView, filters);
                    var con      = new Connection();
                    var result   = con.SelectData(query);

                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #4
0
        public HttpResponseMessage UpdateSessionClient(string token, int clientId)
        {
            try
            {
                using (var con = new OrgSys2017DataContext())
                {
                    var isSessionActive = con.CheckIfTokenValid(token) == 10001;
                    if (!isSessionActive)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                    }

                    var session        = con.Sessions.Single(x => x.SessionToken == token);
                    var user           = con.Users.Single(x => x.UserID == int.Parse(session.UserID));
                    var isInternalUser = user.UserType == 1;
                    //all internal users have a default clientId of 0 in session table
                    var hasPermission = (isInternalUser && clientId == 0) ? true : con.ClientDivisionUserViews.Any(x => x.UserID == user.UserID && x.RootClientID == clientId);

                    if (!hasPermission || !isInternalUser)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Forbidden));
                    }

                    con.Sessions.Single(x => x.SessionToken == token).ClientID = clientId + "";
                    con.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #5
0
        // POST: api/ProductionSchedule
        public string Post(HttpRequestMessage value)
        {
            try
            {
                string  message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JObject json    = JObject.Parse(message);

                DateTime date = new DateTime();
                date = (DateTime)json["date"];

                Production_Schedule ps = new Production_Schedule();
                ps = (from p in db.Production_Schedule
                      where DbFunctions.TruncateTime(p.Production_Schedule_Date) == DbFunctions.TruncateTime(date)
                      select p).FirstOrDefault();

                if (ps == null)
                {
                    generateProductionSchedule();
                }
                else
                {
                    return("false|Production schedule has already been generated.");
                }

                return("true|Succesfully generated production schedule.");
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "ProductionScheduleController POST");
                return("false|Failed to generate Production Schedule.");
            }
        }
Example #6
0
        // GET: api/PartType/5
        public string Get(int id)
        {
            try
            {
                JObject result = JObject.FromObject(new
                {
                    blueprints =
                        from p in db.Part_Blueprint
                        orderby p.Name
                        where p.Part_Type_ID == id
                        select new
                    {
                        Name         = p.Name,
                        Blueprint_ID = p.Blueprint_ID,
                        File_Type    = p.File_Type,
                        Removed      = false
                    }
                });
                return("true|" + result.ToString());
            }


            catch (Exception e)
            {
                ExceptionLog.LogException(e, "BluePrintController GET ID");
                return("false|Failed to retrieve blueprints for part type # " + id + ".");
            }
        }
 // GET: api/UniqueRawMaterial/5
 public string Get(int id)
 {
     try
     {
         JObject result = JObject.FromObject(new
         {
             unique_raw_materials =
                 from p in db.Unique_Raw_Material
                 join rm in db.Raw_Material on p.Raw_Material_ID equals rm.Raw_Material_ID
                 orderby rm.Name
                 where p.Unique_Raw_Material_ID == id
                 select new
             {
                 Raw_Material_ID          = p.Raw_Material_ID,
                 Raw_Material_Name        = rm.Name,
                 Raw_Material_Description = rm.Description,
                 Unique_Raw_Material_ID   = p.Unique_Raw_Material_ID,
                 Dimension         = p.Dimension,
                 Quality           = p.Quality,
                 Date_Added        = p.Date_Added,
                 Date_Used         = p.Date_Used,
                 Cost_Price        = p.Cost_Price,
                 Supplier_Order_ID = p.Supplier_Order_ID
             }
         });
         return("true|" + result.ToString());
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e, "UniqueRawMaterial GET ID");
         return("false|Failed to retrieve Unique Raw Material.");
     }
 }
Example #8
0
        public HttpResponseMessage GetPortalClaimManagerData(string Token, string StatusString, [FromBody] ClaimManagerFieldList Fields)
        {
            try
            {
                var status = "";
                switch (StatusString)
                {
                case "open":
                    status = "(9, 19)";
                    break;

                case "closed":
                    status = "(29)";
                    break;

                case "draft":
                    status = "(0)";
                    break;

                default:
                    status = "";
                    break;
                }

                var qservice = new QueryService("Claims", "Claim", Token);
                //if the same table needs to be joined multiple times, the correct aliases must be referenced in [PermissionDataFilter] table
                //qservice.JoinTableList.Add($" LEFT JOIN [Claim_UserAssigned] ON [Claim_UserAssigned].[ClaimReferenceNumber] = [Claims].[ClaimRefNu] ");
                qservice.JoinTableList.Add($" INNER JOIN [User_Profiles] ON [User_Profiles].[UserID] = [Session].[UserID] ");
                qservice.WhereClauseQueryList.Add($" [Claims].ClientID = [ClientDivisionUserView].[ClientID] ");
                qservice.WhereClauseQueryList.Add($" [Claims].[Status] IN {status} ");
                qservice.WhereClauseQueryList.Add($" [Claims].Archived = 0 ");
                qservice.WhereClauseQueryList.Add($" Claims.Description  IN(SELECT SL.Abbreviation FROM User_Service_Permission as USP INNER JOIN Services_LookUp as SL on USP.ServiceTypeID = SL.ServiceID WHERE USP.UserID = Session.UserID AND Claims.ClientID = USP.ClientID)");
                qservice.SelectColumnList.Add("[Claims].ClaimID");
                qservice.SelectColumnList.Add("[Claims].Description");

                context = new OrgSys2017DataContext();
                var filters      = context.GetFilteredData(Token, "Claim")?.ToList();
                var UserRoleName = context.GetUserRole(Token).FirstOrDefault()?.RoleName; //at this time, users are only assigned a single role

                if ((filters == null && UserRoleName != "OSIUser") || UserRoleName == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden));
                }

                var dataView = context.GetPortalPortalDataView(Token, "Claim").ToList();
                var query    = qservice.BuildQueryFromPermissions(dataView, filters);
                var con      = new Connection();
                var result   = con.SelectData(query);

                var response = Request.CreateResponse();
                response.Content = new StringContent(result);

                return(response);
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
 // GET: api/UniqueMachineStatusses
 public string Get()
 {
     try
     {
         JObject result = JObject.FromObject(new
         {
             unique_machine_statuses =
                 from p in db.Machines join b in db.Unique_Machine on p.Machine_ID equals b.Machine_ID
                 orderby p.Name
                 select new
             {
                 Unique_Machine_ID     = b.Unique_Machine_ID,
                 Unique_Machine_Serial = b.Unique_Machine_Serial,
                 Machine_Status_ID     = b.Machine_Status_ID,
                 Manufacturer          = p.Manufacturer,
                 Model = p.Model,
                 Name  = p.Name
             }
         });
         return("true|" + result.ToString());
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e, "UniqueMachineStatusController GET");
         return("false|Failed to retrieve Unique Machines Statuses.");
     }
 }
        // POST: api/UniqueMachineStatusses
        public string Post(HttpRequestMessage value)
        {
            try
            {
                Model.Unique_Machine mach = new Model.Unique_Machine();

                string message        = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JArray machineDetails = JArray.Parse(message);

                foreach (JObject mac in machineDetails)
                {
                    int um_ID = (int)mac["Unique_Machine_ID"];
                    mach = (from p in db.Unique_Machine
                            where p.Unique_Machine_ID == um_ID
                            select p).First();

                    mach.Machine_Status_ID = (int)mac["Machine_Status_ID"];
                }
                db.SaveChanges();

                return("true|Unique Machine Statuses successfully updated.");
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "UniqueMachineStatusController POST");
                return("false|An error has occured updating the Unique Machine Statuses on the system.");
            }
        }
Example #11
0
        public HttpResponseMessage GetUserProfile(string token)
        {
            try
            {
                using (OrgSys2017DataContext context = new OrgSys2017DataContext())
                {
                    UserProfile profile = new UserProfile();
                    var         USER_ID = context.GetUserIDSession(token).SingleOrDefault().UserID;

                    //gets the two most recent sessions by ther user
                    var LastLoginTime = (from Session in context.Sessions
                                         where Session.UserID == USER_ID.ToString()
                                         orderby Session.SessionID descending
                                         select Session).Take(2).ToList();

                    var UserName = (from User_Profile in context.User_Profiles
                                    where User_Profile.UserID == USER_ID
                                    select User_Profile.EmpFirstName + " " + User_Profile.EmpLastName);

                    profile.USER_ID          = USER_ID;
                    profile.Name             = UserName.First();
                    profile.previousSessions = LastLoginTime;

                    //return a json object of the 2 most recent sessions
                    return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(profile)));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Example #12
0
        public HttpResponseMessage EmployeeOptionsExternal(string token)
        {
            try
            {
                var         clientId        = con.GetClientIDBySession(token).SingleOrDefault().ClientID;
                var         clientDivisions = con.GetClientDivisions(Convert.ToInt32(clientId));
                List <int?> divisionIds     = clientDivisions.Select(division => division.ClientID).ToList();
                //using the same filter(s) as for claim since user cannot create a claim for an employee they cannot view
                var filters = con.GetFilteredData(token, "Claim").ToList();

                if (filters.FindIndex(f => f.FilterValue == "DIVISION_TREE") > -1)
                {
                    var userProfiles = (from UserProfile in con.User_Profiles
                                        where divisionIds.Contains(UserProfile.ClientID)
                                        select UserProfile).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(userProfiles)));
                }
                else if (filters.FindIndex(f => f.FilterValue == "DIVISION") > -1)
                {
                    var userProfiles = (from UserProfile in con.User_Profiles
                                        where UserProfile.ClientID == clientId
                                        select UserProfile).ToList();
                    return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(userProfiles)));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden));
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #13
0
        public HttpResponseMessage UpdateUser(string token, int userId, [FromBody] User user)
        {
            try
            {
                if (!hasAuthorizedRole(con, token))
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden));
                }

                var target = con.Users.Single(x => x.UserID == userId);
                if (target == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                target.Active = user.Active;
                con.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #14
0
        public HttpResponseMessage Register(string token, [FromBody] UserRegistration user)
        {
            try
            {
                if (!hasAuthorizedRole(con, token))
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden));
                }

                var salt = MembershipProvider.CreateNewSalt();
                var hash = MembershipProvider.GenerateHash(user.PasswordClear, salt);

                var userId = con.OnboardUser(user.Username, hash, Convert.ToBase64String(salt), user.ClientID, user.LastName, user.FirstName, user.DOB, user.Email, user.UserTypeID, user.DivisionID);
                var role   = new User_Role
                {
                    Role_ID     = user.RoleID,
                    UserID      = userId,
                    DateCreated = DateTime.Now,
                    isActive    = true
                };

                con.User_Roles.InsertOnSubmit(role);
                con.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, userId));
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Example #15
0
        protected bool ChangePassword(string token, UserAcc account)
        {
            try
            {
                var isActive = con.ValidatePasswordRecoveryAttempt(token, account.username) == 1;
                if (isActive)
                {
                    var user = con.GetUserInfo(account.username).SingleOrDefault();
                    if (user != null)
                    {                                                                //check if the user actually exists
                        string SHASalt   = MembershipProvider.CreateNewSaltString(); //Create Salt String
                        byte[] saltBytes = Convert.FromBase64String(SHASalt);        //Convert Salt String
                        //Generte Hash and Salt for new password and add it to the Database
                        var SHAHash = MembershipProvider.GenerateHash(account.password, saltBytes);
                        //used only for external, so set permission to 2
                        con.Set_PasswordPermissions(user.UserID.ToString(), SHAHash, SHASalt);

                        return(true);
                    }
                    else
                    {
                        return(false); //user doesnt exist
                    }
                }
                else
                {
                    return(false); //username is null
                }
            }
            catch (Exception ex)
            {
                ExceptionLog.LogException(ex);
                return(false); //error occured
            }
        }
Example #16
0
        public HttpResponseMessage GetClientLogo(string token)
        {
            try
            {
                using (context = new OrgSys2017DataContext())
                {
                    var logoFileName = context.GetClientLogo(token).SingleOrDefault().LogoPath;
                    var filePath     = $@"\\OSI-DEV01\umbrella\logos\{logoFileName}";

                    var mimeType   = Path.GetExtension(filePath) == "png" ? "image/png" : "image/jpeg";
                    var logoBytes  = File.ReadAllBytes(filePath);
                    var base64Data = Convert.ToBase64String(logoBytes);

                    var response = new HttpResponseMessage(HttpStatusCode.OK);
                    response.Content = new StringContent(JsonConvert.SerializeObject(new { imageBase64 = $"data:{mimeType};base64,{base64Data}" }));

                    return(response);
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
        // GET: api/SupplierQuote
        public string Get()
        {
            try
            {
                JObject result = JObject.FromObject(new
                {
                    supplier_quotes =
                        from p in db.Supplier_Quote
                        select new
                    {
                        Supplier_Quote_ID          = p.Supplier_Quote_ID,
                        Supplier_Quote_Serial      = p.Supplier_Quote_Serial,
                        Supplier_Quote_Date        = p.Supplier_Quote_Date,
                        Supplier_ID                = p.Supplier_ID,
                        Supplier_Name              = p.Supplier.Name,
                        Supplier_Quote_Expiry_Date = p.Supplier_Quote_Expiry_Date,

                        rms =
                            from d in db.Supplier_Quote_Detail_Raw_Material
                            where d.Supplier_Quote_ID == p.Supplier_Quote_ID
                            select new
                        {
                            Raw_Material_ID   = d.Raw_Material_ID,
                            Raw_Material_Name = d.Raw_Material.Name,
                            Quantity          = d.Quantity,
                            Price             = d.Price,
                            Dimension         = d.Dimension
                        },

                        cs =
                            from d in db.Supplier_Quote_Component
                            where d.Supplier_Quote_ID == p.Supplier_Quote_ID
                            select new
                        {
                            Component_ID       = d.Component_ID,
                            Component_Name     = d.Component.Name,
                            Quantity_Requested = d.Quantity_Requested,
                            Price = d.Price
                        },

                        ps =
                            from d in db.Supplier_Quote_Detail_Part
                            where d.Supplier_Quote_ID == p.Supplier_Quote_ID
                            select new
                        {
                            Part_Type_Name = d.Part_Type.Name,
                            Part_Type_ID   = d.Part_Type_ID,
                            Quantity       = d.Quantity,
                            Price          = d.Price
                        }
                    }
                });
                return("true|" + result.ToString());
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "SupplierQuoteController GET");
                return("false|Failed to retrieve Supplier Quotes.");
            }
        }
Example #18
0
        public HttpResponseMessage UpdateBillingItem([FromBody] string billDetails, string token)
        {
            if (con.CheckIfTokenValid(token) != 10001 && con.IsUserInternal(token) == 1)
            {
                return(new HttpResponseMessage(HttpStatusCode.Unauthorized));
            }
            try
            {
                BillingDetail UpdateBill = JsonConvert.DeserializeObject <BillingDetail>(billDetails);
                BillingDetail OldBill    = con.BillingDetails.SingleOrDefault(i => i.BillID == UpdateBill.BillID);

                OldBill.BillDate       = UpdateBill.BillDate;
                OldBill.CompletionDate = UpdateBill.CompletionDate;
                OldBill.BillMethod     = UpdateBill.BillMethod;
                OldBill.BillReason     = UpdateBill.BillReason;
                OldBill.BillDuration   = UpdateBill.BillDuration;
                OldBill.DirectContact  = UpdateBill.DirectContact;
                OldBill.Postage        = UpdateBill.Postage;
                OldBill.Courier        = UpdateBill.Courier;
                OldBill.Billable       = UpdateBill.Billable;
                OldBill.Comments       = UpdateBill.Comments;
                OldBill.ClientID       = UpdateBill.ClientID;
                con.SubmitChanges();
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                ExceptionLog.LogException(ex);
                return(new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new StringContent(JsonConvert.SerializeObject(ex))
                });
            }
        }
 // GET: api/UpdatePartStatus
 public string Get()
 {
     try
     {
         JObject result = JObject.FromObject(new
         {
             parts =
                 from p in db.Parts join pt in db.Part_Type on p.Part_Type_ID equals pt.Part_Type_ID
                 orderby p.Part_Serial
                 where p.Part_Status_ID == 1 || p.Part_Status_ID == 2 || p.Part_Status_ID == 6
                 select new
             {
                 Part_ID        = p.Part_ID,
                 Part_Serial    = p.Part_Serial,
                 Part_Status_ID = p.Part_Status_ID,
                 Date_Added     = p.Date_Added,
                 Name           = pt.Name,
                 Part_Stage     = p.Part_ID,
                 Job_Card_ID    = from j in db.Job_Card
                                  where j.Job_Card_Detail.Any(x => x.Parts.Any(y => y.Part_ID == p.Part_ID))
                                  select j.Job_Card_ID
             }
         });
         return("true|" + result.ToString());
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e, "UpdatePartStatusController GET");
         return("false|Failed to retrieve Part Statuses.");
     }
 }
        private void updateChildren(int part_ID, int status, int job_card_ID)
        {
            try
            {
                if (status == 2)//I.e Completed
                {
                    List <Job_Card_Detail> details = (from d in db.Job_Card_Detail
                                                      where d.Job_Card_ID == job_card_ID
                                                      select d).ToList();

                    foreach (Job_Card_Detail det in details)
                    {
                        List <Part> parts = (from d in db.Parts
                                             where d.Job_Card_Detail.Contains(db.Job_Card_Detail.Where(x => x.Job_Card_Details_ID == det.Job_Card_Details_ID).FirstOrDefault()) &&
                                             d.Parent_ID == part_ID
                                             select d).ToList();

                        foreach (Part p in parts)
                        {
                            if (p.Part_Status_ID == 1 || p.Part_Status_ID == 2 || p.Part_Status_ID == 3)
                            {
                                p.Part_Status_ID = 7;
                            }
                        }
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "JobCardController updateChildren");
            }
        }
        // POST: api/UpdatePartStatus
        public string Post(HttpRequestMessage value)
        {
            try
            {
                string message           = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JArray partStatusDetails = JArray.Parse(message);

                foreach (JObject partObject in partStatusDetails)
                {
                    Model.Part ps      = new Model.Part();
                    int        part_id = (int)partObject["Part_ID"];

                    ps = (from p in db.Parts
                          where p.Part_ID == part_id
                          select p).First();

                    ps.Part_Status_ID = (int)partObject["Part_Status_ID"];
                }

                db.SaveChanges();
                return("true|Part Statuses successfully updated on the system.");
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "UpdatePartStatusController POST");
                return("false|An error has occured updating the Part Statuses on the system.");
            }
        }
        public ActionResult UpdateRepairLineItems(string uniqueId, string serviceOrderNo, string serialNumberList, string serviceOrderRelation, string conditionId, string symptomAreaId, string symptomCodeId, string diagnosisAreaId, string diagnosisCodeId, string resolutionId, string repairStageId, string technicianNo, string description, string serviceComments)
        {
            string userName  = null;
            bool   isSuccess = false;

            try
            {
                userName = User.Identity.Name.ToString().Split('\\')[1];
                RepairType repairType = new RepairType();
                isSuccess = repairType.UpdateRepairLineItems(uniqueId, serviceOrderNo, serialNumberList, conditionId, symptomAreaId, symptomCodeId, diagnosisAreaId, diagnosisCodeId, resolutionId, repairStageId, technicianNo, description, serviceComments, userName);

                if (isSuccess)
                {
                    TempData["ServiceOrderId"] = serviceOrderNo;
                    Session["SID"]             = serviceOrderNo;
                }
                ViewData["RepairLinesList"] = GetRepairLinesDetails(TempData["ServiceOrderId"].ToString());
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                if (!isSuccess)
                {
                    ExceptionLog.LogException(ex, userName);
                    throw ex;
                }
            }
            return(View("RepairLineDetails"));
        }
Example #23
0
        public void UpdateClient(string token, [FromBody] Client updatedClient)
        {
            try
            {
                var userId         = context.GetUserIDSession(token).SingleOrDefault().UserID;
                var originalClient = context.Clients
                                     .Where(x => x.ClientID == updatedClient.ClientID)
                                     .SingleOrDefault();
                var propertiesNotUpdated = new List <string> {
                    "User_Groups", "UserID", "LogoPath", "IsActive", "ImportID", "OrgsysDivisionID", "DivisionName", "ParentID"
                };
                var properties = typeof(Client).GetProperties().Where(x => !propertiesNotUpdated.Contains(x.Name));

                //update entity properties
                foreach (var p in properties)
                {
                    p.SetValue(originalClient, p.GetValue(updatedClient));
                }
                originalClient.DateLastUpdated     = DateTime.Now;
                originalClient.LastUpdatedByUserID = userId;

                context.SubmitChanges();
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
            }
        }
 // GET: api/UniqueMachine/5
 public string Get(int id)
 {
     try
     {
         JObject result = JObject.FromObject(new
         {
             unique_machines =
                 from p in db.Unique_Machine
                 orderby p.Unique_Machine_Serial
                 where p.Unique_Machine_ID == id
                 select new
             {
                 Unique_Machine_ID     = p.Unique_Machine_ID,
                 Unique_Machine_Serial = p.Unique_Machine_Serial,
                 Machine_Status_ID     = p.Machine_Status_ID,
                 Machine_ID            = p.Machine_ID
             }
         });
         return("true|" + result.ToString());
     }
     catch (Exception e)
     {
         ExceptionLog.LogException(e, "UniqueMachineController GET ID");
         return("false|Failed to retrieve Unique Machines.");
     }
 }
Example #25
0
        public void AddClient(string token, [FromBody] Client client)
        {
            try
            {
                var userId    = context.GetUserIDSession(token).SingleOrDefault().UserID;
                var userGroup = new User_Group
                {
                    UserID     = userId,
                    AssignDate = DateTime.Now,
                    DateFrom   = DateTime.Now,
                    DateTo     = new DateTime(2020, 01, 01)
                };

                client.DateLastUpdated     = DateTime.Now;
                client.LastUpdatedByUserID = userId;
                client.User_Groups.Add(userGroup);

                context.Clients.InsertOnSubmit(client);
                context.SubmitChanges();
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
            }
        }
        public ActionResult GetServiceOrderLineBySerialNumberOrderProcess(string serialNumber)
        {
            string                  userName = null;
            ServiceOrderLine        serviceOrderLineObject = new ServiceOrderLine();
            List <ServiceOrderLine> serviceOrderLineList   = new List <ServiceOrderLine>();

            userName = User.Identity.Name.ToString().Split('\\')[1];
            try
            {
                if (!String.IsNullOrEmpty(serialNumber))
                {
                    serviceOrderLineList = serviceOrderLineObject.GetServiceOrderLinesDetailsBySerialNumber(serialNumber, "", userName);
                    if (serviceOrderLineList.Count > 0)
                    {
                        serviceOrderLineObject.PartNumber     = serviceOrderLineList[0].PartNumber;
                        serviceOrderLineObject.Warranty       = serviceOrderLineList[0].Warranty;
                        serviceOrderLineObject.RepairType     = serviceOrderLineList[0].RepairType;
                        serviceOrderLineObject.LineProperty   = serviceOrderLineList[0].LineProperty;
                        ViewData["ServiceOrderLineinProcess"] = serviceOrderLineList;
                    }
                }
                else
                {
                    serviceOrderLineObject.ServiceOrderLineList = serviceOrderLineList;
                    ViewData["ServiceOrderLineinProcess"]       = serviceOrderLineObject;
                }
                TempData.Keep();
            }
            catch (Exception ex)
            {
                TempData.Keep();
                ExceptionLog.LogException(ex, userName);
            }
            return(View("PartDetailsView", serviceOrderLineObject));
        }
Example #27
0
        public void UpdateClientContact(string token, [FromBody] Client_Contact updatedClientContact)
        {
            try
            {
                var userId = context.GetUserIDSession(token).SingleOrDefault().UserID;
                var originalClientContact = context.Client_Contacts
                                            .Where(x => x.ContactID == updatedClientContact.ContactID)
                                            .SingleOrDefault();
                var properties = typeof(Client_Contact).GetProperties();

                //update entity properties
                foreach (var p in properties)
                {
                    p.SetValue(originalClientContact, p.GetValue(updatedClientContact));
                }
                originalClientContact.DateLastUpdated     = DateTime.Now;
                originalClientContact.LastUpdatedByUserID = userId;

                context.SubmitChanges();
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
            }
        }
Example #28
0
        public HttpResponseMessage GetReportedComments(string Token, string ClaimID)
        {
            try
            {
                if (context.CheckIfTokenValid(Token) == 10001)
                {
                    using (var command = OrgsysdbConn.CreateCommand())
                    {
                        OrgsysdbConn.Open();
                        command.CommandText = "PORTALORG_GetReportedCommentsByClaimID";
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@ClaimID", ClaimID);

                        var da = new MySqlDataAdapter(command);
                        var dt = new DataTable();
                        da.Fill(dt);
                        OrgsysdbConn.Close();

                        return(Request.CreateResponse(HttpStatusCode.OK, JsonConvert.SerializeObject(dt, Formatting.None)));
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
        // POST: api/PriceList
        public string Post(HttpRequestMessage value)
        {
            try
            {
                string  message = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JObject json    = JObject.Parse(message);

                JObject clientDetails  = (JObject)json["client"];
                JArray  contactDetails = (JArray)clientDetails["contact_details"];
                JArray  parts          = (JArray)json["parts"];
                int     c = (int)json["c_ID"];

                string to      = (string)contactDetails[c]["Email_Address"];
                string subject = "WME Price List";

                string body = "Walter Meano Engineering Price List for " + (string)clientDetails["Name"] + "\n\nItems on Price List:\n";

                foreach (JObject part in parts)
                {
                    body += (string)part["Name"] + "\t\tR " + (decimal)part["Selling_Price"] + " per unit\n";
                }

                Email.SendEmail(to, subject, body);
                return("true|Price List successfully sent to " + to);
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "PriceListController");
                return("false|An error has occured sending the email to the customer.");
            }
        }
Example #30
0
        // PUT: api/Component/5
        public string Put(int id, HttpRequestMessage value)
        {
            try
            {
                Component component = new Component();
                component = (from p in db.Components
                             where p.Component_ID == id
                             select p).First();

                string  message         = HttpContext.Current.Server.UrlDecode(value.Content.ReadAsStringAsync().Result).Substring(5);
                JObject json            = JObject.Parse(message);
                JObject cmpDetails      = (JObject)json["component"];
                JArray  supplierDetails = (JArray)json["suppliers"];

                component.Quantity    = (int)cmpDetails["Quantity"];
                component.Unit_Price  = (decimal)cmpDetails["Unit_Price"];
                component.Description = (string)cmpDetails["Description"];
                component.Dimension   = (string)cmpDetails["Dimension"];
                component.Name        = (string)cmpDetails["Name"];
                component.Min_Stock   = (int)cmpDetails["Min_Stock"];

                string errorString = "false|";
                bool   error       = false;

                if ((from t in db.Components
                     where t.Name == component.Name && t.Component_ID != id
                     select t).Count() != 0)
                {
                    error        = true;
                    errorString += "The Component name entered already exists on the system. ";
                }

                if (error)
                {
                    return(errorString);
                }

                db.Component_Supplier.RemoveRange(db.Component_Supplier.Where(x => x.Component_ID == id));

                foreach (JObject supplier in supplierDetails)
                {
                    Component_Supplier cs = new Component_Supplier();
                    cs.Component_ID = id;
                    cs.Supplier_ID  = (int)supplier["Supplier_ID"];
                    cs.is_preferred = Convert.ToBoolean(Convert.ToInt32(supplier["Is_Prefered"]));
                    cs.unit_price   = (decimal)supplier["unit_price"];

                    db.Component_Supplier.Add(cs);
                }

                db.SaveChanges();
                return("true|Component successfully updated.");
            }
            catch (Exception e)
            {
                ExceptionLog.LogException(e, "ComponentController PUT");
                return("false|An error has occured updating the Component on the system.");
            }
        }