public CommonResponse ReadbyName(MOTagHeader e)//by MO and Ln { CommonResponse response = new CommonResponse(); if (e.MO != "" && e.MO_Ln != "") { using (CAPA_INVContext context = new CAPA_INVContext()) { e = context.MOTagHeaders.FirstOrDefault(r => (r.MO == e.MO && r.MO_Ln == e.MO_Ln)); if (e != null) { response.Success(e, "OK"); return response; } else { response.Error("MO Tag Header was not found.", null); return response; } } } else { response.Error("MO and Ln can not be empty.", null); return response; } }
public CommonResponse ReadbyId(User e) { CommonResponse response = new CommonResponse(); if (e.id > 0) { using (CAPA_INVContext context = new CAPA_INVContext()) { e = context.Users.FirstOrDefault(r => r.UserKey == e.id); if (e != null) { response.Success(e, "OK"); return(response); } else { response.Error("User Id was not found.", null); return(response); } } } else { response.Error("User ID can not be 0.", null); return(response); } }
public CommonResponse ReadbyName(V_FSTI_Transaction e) { CommonResponse response = new CommonResponse(); if (e.TransactionStringFields != "") { using (CAPA_INVContext context = new CAPA_INVContext()) { e = context.V_FSTI_Transaction.FirstOrDefault(r => r.TransactionStringFields.Contains(e.TransactionStringFields)); if (e != null) { response.Success(e, "OK"); return(response); } else { response.Error("Transaction Field was not found.", null); return(response); } } } else { response.Error("Transaction Field can not be empty.", null); return(response); } }
public CommonResponse ReadbyId(MOTagHeader e) { CommonResponse response = new CommonResponse(); if (e.MOTagHeaderKey > 0) { using (CAPA_INVContext context = new CAPA_INVContext()) { e = context.MOTagHeaders.FirstOrDefault(r => r.Ticket.TicketKey == e.Ticket.TicketKey); if (e != null) { response.Success(e, "OK"); return response; } else { response.Error("MO Tag Header was not found.", null); return response; } } } else { response.Error("Inventory Event ID can not be 0.", null); return response; } }
public CommonResponse ReadbyId(V_FSTI_Transaction e) { CommonResponse response = new CommonResponse(); if (e.id > 0) { using (CAPA_INVContext context = new CAPA_INVContext()) { e = context.V_FSTI_Transaction.FirstOrDefault(r => r.FSTI_Transaction_key == e.id); if (e != null) { response.Success(e, "OK"); return(response); } else { response.Error("Transaction Id was not found.", null); return(response); } } } else { response.Error("Transaction ID can not be 0.", null); return(response); } }
public CommonResponse GetLastTagID(Ticket e) { CommonResponse response = new CommonResponse(); using (CAPA_INVContext context = new CAPA_INVContext()) { int?TagCounter; try { TagCounter = context.Tickets.Where(q => q.InventoryEventKey == e.InventoryEventKey).Max(r => r.TicketCounter); } catch { TagCounter = 0; } //Ticket _ticket = context.Tickets.Max(r => r.TicketCounter); if (TagCounter != null && TagCounter > 0) { e.TicketCounter = Convert.ToInt32(TagCounter); e = (Ticket)GetbyTagNo(e).Result; response.Success(e, "OK"); return(response); } else { response.Error("Ticket ID was not found.", null); return(response); } } }
public CommonResponse SendMail() { CommonResponse response = new CommonResponse(); try { server.EnableSsl = true; server.DeliveryMethod = SmtpDeliveryMethod.Network; server.UseDefaultCredentials = false; server.Credentials = new System.Net.NetworkCredential(EmailAddress, Password); MailMessage message = new MailMessage(); message.From = new MailAddress(From, From); foreach (var to in To) { message.To.Add(new MailAddress(to)); } message.Subject = Subject; message.IsBodyHtml = true; message.BodyEncoding = System.Text.Encoding.UTF8; message.Body = Body; server.Send(message); } catch (System.Exception ex) { return(response.Error(ex.Message)); } return(response.Success()); }
public CommonResponse SendTestEmail([FromBody] string user) { CommonResponse response = new CommonResponse(); User entity; try { entity = JsonConvert.DeserializeObject <User>(user); EmailService email = new EmailService("secure.emailsrvr.com", 587); email.EmailAddress = entity.Email; email.Password = entity.EmailPassword; email.From = entity.Email; email.To.Add(entity.Email); email.Subject = "Test Email from MRO System."; email.Body = "This is a Test Email sent from MRO System."; email.SendMail(); return(response.Success()); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
public static CommonResponse CreateError(string message) { var response = new CommonResponse(); response.Error(message); return(response); }
public static CommonResponse CreateError(string message, string messageCode, object result) { var response = new CommonResponse(); response.Error(message, messageCode, result); return(response); }
public CommonResponse pingError() { CommonResponse response = new CommonResponse(); response.Error(new KnownError("Test has failed this is in porpouse error")); return(response); }
private CommonResponse SetStatus(int ApprovalKey, string Message, string Status) { CommonResponse response = new CommonResponse(); try { var ctx = context as MROContext; var approval = ctx.Approvals.AsNoTracking() .Include(a => a.Approvers) .FirstOrDefault(a => a.ApprovalKey == ApprovalKey); if (approval == null) { throw new KnownError("Approval does not exist."); } if (LoggedUser.Role != "Administrator") { var userValid = approval.Approvers?.FirstOrDefault(u => u.UserKey == LoggedUser.UserID); if (userValid == null) { throw new KnownError("Logged User not lised as Approver."); } } approval.Status = Status; approval.ResponseDescription = Message; approval.DateResponse = DateTimeOffset.Now; approval.StatusUpdatedByKey = LoggedUser.UserID; repository.Update(approval); //Updating Tasks associated: taskLogic.SaveTask(LoggedUser.UserID ?? 0, approval); return(response.Success(_GetByID(ApprovalKey))); } catch (KnownError ke) { return(response.Error(ke)); } catch (Exception e) { return(response.Error(e.ToString())); } }
public CommonResponse getByRole(string role) { CommonResponse response = new CommonResponse(); try { return(logic.GetListWhere(u => u.Value, u => u.Role == role)); } catch (Exception ex) { return(response.Error(ex.ToString())); } }
public CommonResponse CanelCheckout(int id) { var response = new CommonResponse(); try { return(logic.CancelCheckout(id)); } catch (Exception ex) { return(response.Error(ex.Message)); } }
public CommonResponse getByUserName(string userName) { CommonResponse response = new CommonResponse(); try { response.Success(logic.GetSingleWhere(u => u.UserName == userName)); } catch (Exception ex) { return(response.Error(ex.ToString())); } return(response); }
public CommonResponse Checkin([FromBody] string value) { var response = new CommonResponse(); try { var entity = JsonConvert.DeserializeObject <Document>(value); return(logic.Checkin(entity)); } catch (Exception ex) { return(response.Error(ex.Message)); } }
public CommonResponse Reject(int ApprovalKey, [FromBody] string approval) { CommonResponse response = new CommonResponse(); try { Approval oApproval = JsonConvert.DeserializeObject <Approval>(approval); return((logic as IApprovalLogic).Reject(ApprovalKey, oApproval.ResponseDescription)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
//Specific for UserLogic public CommonResponse GetByName(string sName) { CommonResponse response = new CommonResponse(); try { User entity = repository.GetSingle(null, e => e.UserName == sName); AdapterOut(entity); return(response.Success(entity)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
public CommonResponse Commit() { var CommonResponse = new CommonResponse(); try { this.transaction.Commit(); } catch (Exception ex) { CommonResponse.Error("SaveChanges", "ERR001", ex.Message); } return(CommonResponse); }
virtual public CommonResponse Delete([FromBody] string value) { CommonResponse response = new CommonResponse(); Entity entity; try { entity = JsonConvert.DeserializeObject <Entity>(value); return(_logic.Remove(entity)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
virtual public CommonResponse Unfinalize([FromBody] string value) { CommonResponse response = new CommonResponse(); Document entity; try { entity = JsonConvert.DeserializeObject <Document>(value); return(logic.Unfinalize(entity)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
virtual public CommonResponse Delete([FromBody] string value) { CommonResponse response = new CommonResponse(); Entity entity; try { entity = JsonConvert.DeserializeObject <Entity>(value); return(logic.Remove(entity)); } catch (Exception e) { var originalException = GetOriginalException(e); return(response.Error("Error " + originalException.Message)); } }
virtual public CommonResponse SetProperty(string sProperty, string newValue, [FromBody] string value) { CommonResponse response = new CommonResponse(); Entity entity; try { entity = JsonConvert.DeserializeObject <Entity>(value); return(_logic.SetPropertyValue(entity, sProperty, newValue)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
public override CommonResponse GetAll() { CommonResponse response = new CommonResponse(); IEnumerable <User> entities; try { repository.byUserId = loggedUser.UserID; entities = repository.GetList(u => u.Value, u => u.sys_active == true && u.Role != "Administrator"); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } return(response.Success(entities)); }
virtual public CommonResponse SetProperty(string sProperty, string newValue, [FromBody] string value) { CommonResponse response = new CommonResponse(); Entity entity; try { entity = JsonConvert.DeserializeObject <Entity>(value); return(logic.SetPropertyValue(entity, sProperty, newValue)); } catch (Exception e) { var originalException = GetOriginalException(e); return(response.Error("Error " + originalException.Message)); } }
virtual public CommonResponse GetSingleByParent(string parentType, int parentId) { CommonResponse response = new CommonResponse(); try { Type parentClassName = Type.GetType("BusinessSpecificLogic.EF." + parentType + ", BusinessSpecificLogic", true); MethodInfo method = _logic.GetType().GetMethod("GetSingleByParent"); MethodInfo generic = method.MakeGenericMethod(parentClassName); response = (CommonResponse)generic.Invoke(_logic, new object[] { parentId }); return(response); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
public CommonResponse AssignResponsible(int iTrackKey, int iUserKey) { CommonResponse response = new CommonResponse(); try { var ctx = context as MainContext; Track track = ctx.Tracks.FirstOrDefault(t => t.TrackKey == iTrackKey); track.User_AssignedToKey = iUserKey; ctx.SaveChanges(); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } return(response.Success()); }
virtual public CommonResponse Put(int id, [FromBody] string value) { CommonResponse response = new CommonResponse(); Entity entity; try { //JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); //entity = jsonSerializer.Deserialize<Entity>(value); entity = JsonConvert.DeserializeObject <Entity>(value); return(_logic.Update(entity)); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
virtual public CommonResponse GetAvailableForEntity(string sEntityType, int id) { CommonResponse response = new CommonResponse(); try { Type forEntityType = Type.GetType("BusinessSpecificLogic.EF." + sEntityType + ", BusinessSpecificLogic", true); MethodInfo method = _logic.GetType().GetMethod("GetAvailableFor"); MethodInfo generic = method.MakeGenericMethod(forEntityType); response = (CommonResponse)generic.Invoke(_logic, new object[] { id }); return(response); } catch (Exception e) { return(response.Error("ERROR: " + e.ToString())); } }
virtual public CommonResponse GetAllByParent(string parentType, int parentId) { CommonResponse response = new CommonResponse(); try { Type parentClassName = Type.GetType("BusinessSpecificLogic.EF." + parentType + ", BusinessSpecificLogic", true); MethodInfo method = logic.GetType().GetMethod("GetAllByParent"); MethodInfo generic = method.MakeGenericMethod(parentClassName); response = (CommonResponse)generic.Invoke(logic, new object[] { parentId }); return(response); } catch (Exception e) { var originalException = GetOriginalException(e); return(response.Error("Error " + originalException.Message)); } }