Exemplo n.º 1
0
 public IHttpActionResult ASNInitiate([FromBody] ASNInitiation model)
 {
     return(Ok(_asnBusinessAccess.ASNInitiate(model)));
 }
Exemplo n.º 2
0
        /*Name of Function : <<ASNInitiate>>  Author :<<Prasanna>>
         * Date of Creation <<18-12-2020>>
         * Purpose : <<function is used to  get ASN Initiate>>
         * Review Date :<<>>   Reviewed By :<<>>*/
        public bool ASNInitiate(ASNInitiation asnASNInitiation)
        {
            try
            {
                int vendorid = Convert.ToInt32(asnASNInitiation.VendorId);
                //check vuserid exist or not if not exist adding credentials  in vendorusermaster tables
                List <string> EmailList = asnASNInitiation.VendorEmailId.Split(new char[] { ',' }).ToList();
                foreach (var item in EmailList)
                {
                    Int32  sequenceNo = 0;
                    string password   = "";
                    var    value      = "";
                    RemoteVendorUserMaster vendorUsermaster = vscm.RemoteVendorUserMasters.Where(li => li.Vuserid == item && li.VendorId == asnASNInitiation.VendorId).FirstOrDefault();

                    //need to implement vUniqueId value
                    if (vendorUsermaster == null && !string.IsNullOrEmpty(item))
                    {
                        RemoteVendorUserMaster vendorUsermasters = new RemoteVendorUserMaster();
                        sequenceNo = Convert.ToInt32(vscm.RemoteVendorUserMasters.Max(li => li.SequenceNo));
                        if (sequenceNo == null || sequenceNo == 0)
                        {
                            sequenceNo = 1;
                        }
                        else
                        {
                            sequenceNo = sequenceNo + 1;
                        }
                        value = obj.SP_sequenceNumber(sequenceNo).FirstOrDefault();
                        vendorUsermasters.VuniqueId  = "C" + value;
                        vendorUsermasters.SequenceNo = sequenceNo;
                        vendorUsermasters.Vuserid    = item.Replace(" ", String.Empty);
                        password = this.mprDA.GeneratePassword();
                        vendorUsermasters.pwd           = password;
                        vendorUsermasters.ContactNumber = null;
                        vendorUsermasters.ContactPerson = null;
                        vendorUsermasters.VendorId      = vendorid;
                        vendorUsermasters.Active        = true;
                        vendorUsermasters.SuperUser     = true;
                        vendorUsermasters.UpdatedBy     = asnASNInitiation.InitiateFrom;
                        vendorUsermasters.UpdatedOn     = DateTime.Now;
                        vscm.RemoteVendorUserMasters.Add(vendorUsermasters);
                        vscm.SaveChanges();
                    }
                    VendorUserMaster Localvenmaster = obj.VendorUserMasters.Where(li => li.Vuserid == item && li.VendorId == vendorid).FirstOrDefault <VendorUserMaster>();
                    if (Localvenmaster == null && !string.IsNullOrEmpty(item))
                    {
                        RemoteVendorUserMaster venmaster         = vscm.RemoteVendorUserMasters.Where(li => li.Vuserid == item && li.VendorId == vendorid).FirstOrDefault <RemoteVendorUserMaster>();
                        VendorUserMaster       vendorUsermasters = new VendorUserMaster();
                        vendorUsermasters.Vuserid       = venmaster.Vuserid;
                        vendorUsermasters.pwd           = venmaster.pwd;
                        vendorUsermasters.VendorId      = venmaster.VendorId;
                        vendorUsermasters.ContactNumber = venmaster.ContactNumber;
                        vendorUsermasters.ContactPerson = venmaster.ContactPerson;
                        vendorUsermasters.Active        = true;
                        vendorUsermasters.SuperUser     = true;
                        vendorUsermasters.VuniqueId     = venmaster.VuniqueId;
                        vendorUsermasters.SequenceNo    = venmaster.SequenceNo;
                        vendorUsermasters.UpdatedBy     = venmaster.UpdatedBy;
                        vendorUsermasters.UpdatedOn     = DateTime.Now;
                        obj.VendorUserMasters.Add(vendorUsermasters);
                        obj.SaveChanges();
                    }
                }
                ASNInitiation asnIniLocal = new ASNInitiation();
                asnIniLocal.VendorId      = vendorid;
                asnIniLocal.VendorEmailId = asnASNInitiation.VendorEmailId;
                asnIniLocal.Remarks       = asnASNInitiation.Remarks;
                asnIniLocal.InitiateFrom  = asnASNInitiation.InitiateFrom;
                asnIniLocal.CreatedDate   = DateTime.Now;
                obj.ASNInitiations.Add(asnIniLocal);
                obj.SaveChanges();
                this.emailTemplateDA.sendASNInitiationEmail(asnIniLocal);
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        log.ErrorMessage("ASNDA", "ASNInitiate", ve.ErrorMessage);
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 3
0
 public bool ASNInitiate(ASNInitiation ASNInitiation)
 {
     return(_asnDataAcess.ASNInitiate(ASNInitiation));
 }