Ejemplo n.º 1
0
        private void movement(DTOstockmovement r)
        {
            var userID = KOCAuthorizeAttribute.getCurrentUser().userId;

            using (var db = new KOCSAMADLSEntities())
            {
                adsl_stockmovement sm = new adsl_stockmovement();
                sm.serialno       = r.serialno;
                sm.lastupdated    = DateTime.Now;
                sm.updatedby      = userID;
                sm.creationdate   = DateTime.Now;
                sm.toobjecttype   = r.toobjecttype;
                sm.stockcardid    = r.stockcardid;
                sm.toobject       = r.toobject;
                sm.deleted        = false;
                sm.amount         = r.amount;
                sm.fromobjecttype = r.fromobjecttype;
                sm.fromobject     = r.fromobject;
                sm.movementdate   = DateTime.Now;
                if (r.fromobjecttype == 16777217 || r.toobjecttype == 16777217 || r.fromobjecttype == 33554433)
                {
                    sm.confirmationdate = DateTime.Now;                                                                                             // hareket müşteridense onaylı olmalı
                }
                sm.updatedby = userID;
                db.stockmovement.Add(sm);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage deleteSL(int SLID)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var upa = db.SL.Where(r => r.SLID == SLID).FirstOrDefault();
                        //upa.deleted = true; //delete işlemi sayfadan yapılacaksa aktif edilip işlem burdan sağlanacak (Hüseyin KOZ)
                        upa.lastupdated = DateTime.Now;
                        upa.updatedby   = user.userId;
                        db.SaveChanges();
                        tran.Commit();
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "işlem Gerçekleştirildi."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "işlem Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                    }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage updateSL(DTOSL request)
        { // SL hesaplamaları için gerekli olan bilgilerin güncellenmesi (Hüseyin KOZ)
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var upa = db.SL.Where(r => r.SLID == request.SLID).FirstOrDefault();
                        upa.SLName      = request.SLName;
                        upa.KocSTask    = request.KocSTask;
                        upa.KocETask    = request.KocETask;
                        upa.KocMaxTime  = request.KocMaxTime;
                        upa.BayiSTask   = request.BayiSTask;
                        upa.BayiETask   = request.BayiETask;
                        upa.BayiMaxTime = request.BayiMaxTime;
                        upa.lastupdated = DateTime.Now;
                        upa.updatedby   = user.userId;
                        db.SaveChanges();
                        tran.Commit();
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "SL Düzenleme Tamamlandı."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "SL Düzenleme Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                    }
        }
Ejemplo n.º 4
0
        public HttpResponseMessage saveCustomerCard(DTOKatZiyareti ct)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                if (db.customer.Any(c => c.customerid == ct.customerid))
                {
                    var item = db.customer.Where(c => c.customerid == ct.customerid).First();

                    item.customername = ct.customername;
                    //item.customersurname = ct.customersurname;
                    item.gsm               = ct.gsm;
                    item.netstatu          = ct.netStatus.id;
                    item.telstatu          = ct.telStatus.id;
                    item.gsmstatu          = ct.gsmKullanımıStatus.id;
                    item.iss               = ct.issStatus.id;
                    item.tvstatu           = ct.TvKullanımıStatus.id;
                    item.description       = ct.description;
                    item.lastupdated       = DateTime.Now;
                    item.updatedby         = user.userId;
                    item.superonlineCustNo = ct.superonlineCustNo;
                }
                if (ct.closedKatZiyareti == true)
                {
                    var res = db.taskqueue.Where(tq => tq.attachedobjectid == ct.customerid && tq.taskid == 86 && tq.status == null).FirstOrDefault();
                    res.status           = 1079;
                    res.consummationdate = DateTime.Now;
                    res.lastupdated      = DateTime.Now;
                }

                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, "ok", "application/json"));
            }
        }
Ejemplo n.º 5
0
        public HttpResponseMessage getStocksOnPersonel(DTOGetPersonelStock request)
        { // Personellerin Üzerlerindeki serileri görebilmeleri için oluşturuldu (Stok-seri kontrolü)
            ArrayList list     = new ArrayList();
            var       user     = KOCAuthorizeAttribute.getCurrentUser();
            var       personel = request.personelid != null ? request.personelid.Value : user.userId;

            using (var db = new KOCSAMADLSEntities())
            {
                var type = db.stockcard.ToList();
                for (int i = 0; i < type.Count; i++)
                {
                    var serials = db.getSerialsOnPersonelAdsl(personel, type[i].stockid).ToList();
                    for (int j = 0; j < serials.Count; j++)
                    {
                        DTOStockReturn res = new DTOStockReturn();
                        res.stockid    = type[i].stockid;
                        res.stockname  = type[i].productname;
                        res.personelid = personel;
                        res.serials    = serials[j];
                        list.Add(res);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, list, "application/json"));
            }
        }
        public HttpResponseMessage savePE(DTOSavePenetrasyon request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var taskqueue = new taskqueue
                {
                    attachedobjectid   = request.blockid,
                    attachedpersonelid = request.attachedpersonelid,
                    creationdate       = request.date != null ? request.date : DateTime.Now,
                    deleted            = false,
                    description        = "İnternet Penetrasyon Taskı",
                    lastupdated        = DateTime.Now,
                    status             = null,
                    taskid             = 8164,
                    updatedby          = user.userId
                };
                db.taskqueue.Add(taskqueue);
                db.SaveChanges();
                taskqueue.relatedtaskorderid = taskqueue.taskorderno; // başlangıç tasklarının relatedtaskorderid kendi taskorderno tutacak (Hüseyin KOZ) 13.03.2017
                db.SaveChanges();
            }

            return(Request.CreateResponse(HttpStatusCode.OK, "İşlem Başarılı", "application/json"));
        }
Ejemplo n.º 7
0
        public HttpResponseMessage getSerialOnCustomer(adsl_stockmovement request)
        { // gönderilen filtre sorgusu sonucu bulunan müşteriye stok hareketlerinden halen müşteride bulunan stoklardan movemenid'si küçük olanı döndürür (lazım olursa liste yapılıp döndürülebilir)
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
            {
                var ret = db.getSerialsOnCustomerAdsl(request.fromobject, request.stockcardid).ToList();
                return(Request.CreateResponse(HttpStatusCode.OK, ret, "application/json"));
            }
        }
Ejemplo n.º 8
0
        public HttpResponseMessage getSerialOnPersonel(adsl_stockmovement request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
            {
                var ret = db.getSerialsOnPersonelAdsl(request.fromobject, request.stockcardid).ToList();
                return(Request.CreateResponse(HttpStatusCode.OK, ret, "application/json"));
            }
        }
        public HttpResponseMessage saveTtvTask(DTONewTTVTask request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var c  = db.customer.First(r => r.customerid == request.customerid);
                var cs = new customer
                {
                    superonlineCustNo = request.customer.superonlineCustNo,
                    tckimlikno        = request.customer.tckimlikno,
                    customername      = request.customer.customername,
                    gsm            = request.customer.gsm,
                    phone          = request.customer.phone,
                    customerstatus = request.customer.customerstatus,
                    iss            = request.customer.iss,
                    netstatu       = request.customer.netstatu,
                    telstatu       = request.customer.telstatu,
                    tvstatu        = request.customer.tvstatu,
                    turkcellTv     = request.customer.turkcellTv,
                    gsmstatu       = request.customer.gsmstatu,
                    description    = request.customer.description,
                    blockid        = c.blockid,
                    flat           = c.flat,
                    creationdate   = DateTime.Now,
                    lastupdated    = DateTime.Now,
                    updatedby      = user.userId,
                    deleted        = false
                };
                db.customer.Add(cs);
                c.deleted = null;
                db.SaveChanges();
                var taskqueue = new taskqueue
                {
                    taskid             = request.taskid,
                    creationdate       = request.creationdate != null ? request.creationdate : DateTime.Now,
                    attachedobjectid   = cs.customerid,
                    attachmentdate     = request.attachedpersonelid != null ? DateTime.Now : (DateTime?)null,
                    attachedpersonelid = request.attachedpersonelid,
                    description        = request.description,
                    lastupdated        = DateTime.Now,
                    deleted            = false,
                    updatedby          = user.userId
                };
                db.taskqueue.Add(taskqueue);
                db.SaveChanges();
                taskqueue.relatedtaskorderid = taskqueue.taskorderno; // başlangıç tasklarının relatedtaskorderid kendi taskorderno tutacak (Hüseyin KOZ) 13.03.2017
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, taskqueue.taskorderno, "application/json"));
            }
        }
Ejemplo n.º 10
0
        public HttpResponseMessage confirmSM(int[] movementIds)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();
            DTOResponseError errormessage = new DTOResponseError();

            if (movementIds.Length > 0)
            {
                using (var db = new KOCSAMADLSEntities())
                    using (var tran = db.Database.BeginTransaction())
                        try
                        {
                            //yalnızca kendine çıkılan stoklar onaylanabilir
                            if (db.stockmovement.Where(s => movementIds.Contains(s.movementid)).Any(a => a.toobject == user.userId))
                            {
                                foreach (var item in movementIds)
                                {
                                    var sm = db.stockmovement.Where(s => s.movementid == item && s.confirmationdate == null).FirstOrDefault();
                                    sm.confirmationdate = DateTime.Now;
                                    sm.updatedby        = user.userId;
                                    sm.lastupdated      = DateTime.Now;
                                }
                                db.SaveChanges();
                                tran.Commit();
                                errormessage.errorMessage = "Onaylama işlemi başarılı";
                                errormessage.errorCode    = 1;
                                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                            }
                            else
                            {
                                errormessage.errorMessage = "Sadece Üzerinize Atanmış Stokları Onaylayabilirsiniz";
                                errormessage.errorCode    = -1;
                                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                            }
                        }
                        catch (Exception)
                        {
                            tran.Rollback();
                            errormessage = new DTOResponseError {
                                errorCode = 2, errorMessage = "işlem Tamamlanamadı!"
                            };
                            return(Request.CreateResponse(HttpStatusCode.NotModified, errormessage, "application/json"));
                        }
            }
            else
            {
                errormessage.errorMessage = "Onaylamak İçin En Az 1 Stok Hareketi Seçmelisiniz!";
                errormessage.errorCode    = -1;
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 11
0
        public HttpResponseMessage SaveStockMovement(stockmovement r, int?tqid, string serinos)
        {
            var userID = KOCAuthorizeAttribute.getCurrentUser().userId;

            if (r.movementid <= 0)
            {
                return(InsertStockMovement(r, tqid, serinos));
            }
            else
            {
                using (var db = new CRMEntities())
                {
                    var Records = db.stockmovement.Include(s => s.stockcard).Where(s => s.movementid == r.movementid);
                    if (Records.Count() > 0)
                    {
                        //var confirmationroles = (new KocCRMRoles[]{
                        //        KocCRMRoles.kscrProductionStaff,
                        //        KocCRMRoles.kscrSalesStaff,
                        //        KocCRMRoles.kscrStockStaff,
                        //        KocCRMRoles.kscrTechnicalStaff,
                        //        KocCRMRoles.kscrBackOfficeStaff,
                        //        KocCRMRoles.kscrCallCenterStaff
                        //    }).Select(role => (long)role).ToList();
                        var Record = Records.First();

                        if (r.toobject == userID && r.confirmationdate != null && Record.confirmationdate == null)  //confirmationroles.Contains(r.toobjecttype) &&  if şartlarına eklenecek yetkilendirmeden sonra
                        {
                            Record.confirmationdate = DateTime.Now;
                        }
                        else
                        {
                            if (Record.stockcard.hasserial == true && string.IsNullOrWhiteSpace(r.serialno))
                            {
                                return(Request.CreateResponse(HttpStatusCode.OK, tqid, "application/json"));//seri numarası girilmesi gerekirken girilmemişse veya boşluk gibi bir karakter girilmişse
                            }
                            Record.amount           = string.IsNullOrWhiteSpace(r.serialno) ? r.amount : 1;
                            Record.relatedtaskqueue = r.relatedtaskqueue;
                            Record.serialno         = r.serialno;
                            Record.stockcardid      = r.stockcardid;
                            Record.toobject         = r.toobject;
                            Record.toobjecttype     = r.toobjecttype;
                        }
                        Record.updatedby   = userID;
                        Record.lastupdated = DateTime.Now;
                        db.SaveChanges();
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, tqid, "application/json"));
                }
            }
        }
Ejemplo n.º 12
0
        public HttpResponseMessage insertCustomer(DTOcustomer request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "İşlem Başarılı"
                        };
                        var p = new customer
                        {
                            blockid           = request.block.blockid,
                            tckimlikno        = request.tckimlikno,
                            customername      = request.customername,
                            flat              = request.flat,
                            gsm               = request.gsm,
                            phone             = request.phone,
                            birthdate         = request.birthdate,
                            creationdate      = DateTime.Now,
                            lastupdated       = DateTime.Now,
                            updatedby         = user.userId,
                            deleted           = false,
                            customerstatus    = request.customer_status.ID,
                            telstatu          = request.telStatus.id,
                            tvstatu           = request.TvKullanımıStatus.id,
                            turkcellTv        = request.TurkcellTVStatus.id,
                            netstatu          = request.netStatus.id,
                            description       = request.description,
                            gsmstatu          = request.gsmKullanımıStatus.id,
                            iss               = request.issStatus.id,
                            emptorcustomernum = request.emptorcustomernum,
                            superonlineCustNo = request.superonlineCustNo,
                        };
                        db.customer.Add(p);
                        db.SaveChanges();
                        tran.Commit();
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "Hata Oluştu"
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
        }
        public HttpResponseMessage saveDocument(DTOdocument request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var ddoc = db.document.Where(d => d.documentid == request.documentid).FirstOrDefault();
                ddoc.documentname        = request.documentname;
                ddoc.documentdescription = request.documentdescription;
                ddoc.lastupdated         = DateTime.Now;
                ddoc.updatedby           = user.userId;
                db.SaveChanges();

                return(Request.CreateResponse(HttpStatusCode.OK, DTOResponseError.NoError(), "application/json"));
            }
        }
Ejemplo n.º 14
0
        public HttpResponseMessage editSiteMultiple(DTORequestSBEditMultiple request)
        {
            if ((request.siteIds == null && request.blockIds == null) || request.personelid == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Seçimleri Yapınız !", "application/json"));
            }
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        if (request.blockIds != null && request.blockIds.Count > 0)
                        {
                            var k = db.block.Where(r => request.blockIds.Contains(r.blockid)).ToList();
                            k.ForEach(r =>
                            {
                                r.salesrepresentative = request.personelid;
                                r.lastupdated         = DateTime.Now;
                                r.updatedby           = user.userId;
                            });
                        }
                        else
                        {
                            var k = db.block.Where(r => request.siteIds.Contains(r.siteid)).ToList();
                            k.ForEach(r =>
                            {
                                r.salesrepresentative = request.personelid;
                                r.lastupdated         = DateTime.Now;
                                r.updatedby           = user.userId;
                            });
                        }

                        db.SaveChanges();
                        tran.Commit();
                        return(Request.CreateResponse(HttpStatusCode.OK, "Tamamlandı", "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        return(Request.CreateResponse(HttpStatusCode.OK, "Tamamlanmadı", "application/json"));
                    }
                }
        }
        public HttpResponseMessage savetask(DTOSaveGlobalTask request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                if (request.newcustomer)
                { // işlem eğer sadece mobil satış işlemi ise
                    var c  = db.customer.First(r => r.customerid == request.customerid);
                    var cs = new customer
                    {
                        blockid      = c.blockid,
                        customername = request.customername,
                        creationdate = DateTime.Now,
                        description  = "Hat Satışı için Oluşturuldu",
                        flat         = c.flat,
                        gsm          = request.gsm,
                        lastupdated  = DateTime.Now,
                        tckimlikno   = request.tc,
                        updatedby    = user.userId
                    };
                    db.customer.Add(cs);
                    db.SaveChanges();
                    request.customerid = cs.customerid;
                }
                var taskqueue = new taskqueue
                {
                    taskid             = request.taskid,
                    creationdate       = request.creationdate != null ? request.creationdate : DateTime.Now,
                    attachedobjectid   = request.customerid != null ? request.customerid : request.blockid,
                    attachmentdate     = request.attachedpersonelid != null ? DateTime.Now : (DateTime?)null,
                    attachedpersonelid = request.attachedpersonelid,
                    description        = request.description,
                    lastupdated        = DateTime.Now,
                    deleted            = false,
                    fault     = request.fault,
                    updatedby = user.userId
                };
                db.taskqueue.Add(taskqueue);
                db.SaveChanges();
                taskqueue.relatedtaskorderid = taskqueue.taskorderno; // başlangıç tasklarının relatedtaskorderid kendi taskorderno tutacak (Hüseyin KOZ) 13.03.2017
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, taskqueue.taskorderno, "application/json"));
            }
        }
Ejemplo n.º 16
0
        public HttpResponseMessage insertCustomer(customer ct)
        {
            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var item = new customer();
                        item.customername      = ct.customername.ToUpper();
                        item.superonlineCustNo = ct.superonlineCustNo;
                        item.gsm             = ct.gsm;
                        item.tc              = ct.tc;
                        item.phone           = ct.phone;
                        item.birthdate       = ct.birthdate;
                        item.ilKimlikNo      = ct.ilKimlikNo;
                        item.ilceKimlikNo    = ct.ilceKimlikNo;
                        item.bucakKimlikNo   = ct.bucakKimlikNo;
                        item.mahalleKimlikNo = ct.mahalleKimlikNo;
                        item.yolKimlikNo     = 61;
                        item.binaKimlikNo    = 61;
                        item.daire           = 61;
                        item.creationdate    = DateTime.Now;
                        item.lastupdated     = DateTime.Now;
                        item.updatedby       = KOCAuthorizeAttribute.getCurrentUser().userId;
                        item.email           = ct.email;
                        item.deleted         = false;
                        item.description     = ct.description;
                        db.customer.Add(item);
                        db.SaveChanges();

                        tran.Commit();
                        var customer     = db.customer.First(r => r.tc == ct.tc);
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "İşlem Tamamlandı."
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, new { errormessage, customer }, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "İşlem Tamamlanamadı!"
                        };
                        return(Request.CreateResponse(HttpStatusCode.NotModified, new { errormessage }, "application/json"));
                    }
        }
        public HttpResponseMessage saveTaskstate(DTOtaskstatepool request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var dtsp = db.taskstatepool.Where(t => t.taskstateid == request.taskstateid).FirstOrDefault();
                dtsp.taskstate   = request.taskstate;
                dtsp.statetype   = request.statetype;
                dtsp.lastupdated = DateTime.Now;
                dtsp.updatedby   = user.userId;
                db.SaveChanges();
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 18
0
 public HttpResponseMessage saveTaskStateMatches(DTOtaskstatematches request)
 {
     using (var db = new CRMEntities())
     {
         var dtsm = db.taskstatematches.Where(t => t.id == request.id).FirstOrDefault();
         dtsm.taskid             = request.task.taskid;
         dtsm.stateid            = request.taskstatepool.taskstateid;
         dtsm.automandatorytasks = request.automandatorytasks;
         dtsm.autooptionaltasks  = request.autooptionaltasks;
         dtsm.stockcards         = request.stockcards;
         dtsm.documents          = request.documents;
         dtsm.lastupdated        = DateTime.Now;
         dtsm.updatedby          = KOCAuthorizeAttribute.getCurrentUser().userId;
         db.SaveChanges();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Ejemplo n.º 19
0
        public HttpResponseMessage saveProduct(DTOProduct_service request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dpro = db.product_service.Where(t => t.productid == request.productid).FirstOrDefault();

                dpro.productname        = request.productname;
                dpro.category           = request.category;
                dpro.maxduration        = request.maxduration;
                dpro.automandatorytasks = request.automandatorytasks;
                dpro.lastupdated        = DateTime.Now;
                dpro.updatedby          = user.userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 20
0
 public HttpResponseMessage saveCustomerCard(DTOcustomer ct)
 {
     using (var db = new KOCSAMADLSEntities())
         using (var transaction = db.Database.BeginTransaction())
             try
             {
                 var oldCust = db.customer.Where(c => c.tc == ct.tc && c.deleted == false).ToList();
                 if (oldCust.Count == 0 || oldCust.Where(r => r.customerid == ct.customerid).FirstOrDefault() != null)
                 {
                     if (db.customer.Any(c => c.customerid == ct.customerid))
                     {
                         var item = db.customer.Where(c => c.customerid == ct.customerid).First();
                         item.customername      = ct.customername;
                         item.gsm               = ct.gsm;
                         item.tc                = ct.tc;
                         item.ilKimlikNo        = ct.ilKimlikNo;
                         item.ilceKimlikNo      = ct.ilceKimlikNo;
                         item.bucakKimlikNo     = ct.bucakKimlikNo;
                         item.mahalleKimlikNo   = ct.mahalleKimlikNo;
                         item.phone             = ct.phone;
                         item.birthdate         = ct.birthdate;
                         item.lastupdated       = DateTime.Now;
                         item.updatedby         = KOCAuthorizeAttribute.getCurrentUser().userId;
                         item.email             = ct.email;
                         item.superonlineCustNo = ct.superonlineCustNo;
                         item.xdslno            = ct.xdslno;
                         item.description       = ct.description;
                     }
                     db.SaveChanges();
                     transaction.Commit();
                     return(Request.CreateResponse(HttpStatusCode.OK, "ok", "application/json"));
                 }
                 return(Request.CreateResponse(HttpStatusCode.OK, "Girilen TC Numarası Başkasına Aittir", "application/json"));
             }
             catch
             {
                 transaction.Rollback();
                 return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, "error", "application/json"));
             }
 }
        public HttpResponseMessage saveStockCard(DTOstockcard request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var ds = db.stockcard.Where(t => t.stockid == request.stockid).FirstOrDefault();

                ds.productname = request.productname;
                ds.category    = request.category;
                ds.hasserial   = request.hasserial;
                ds.unit        = request.unit;
                ds.description = request.description;
                ds.lastupdated = DateTime.Now;
                ds.updatedby   = user.userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
        public HttpResponseMessage saveCampaigns(DTOcampaigns request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dcamp = db.campaigns.Where(t => t.id == request.id).FirstOrDefault();

                dcamp.name        = request.name;
                dcamp.category    = request.category;
                dcamp.subcategory = request.subcategory;
                dcamp.products    = request.products;
                dcamp.documents   = request.documents;
                dcamp.lastupdated = DateTime.Now;
                dcamp.updatedby   = user.userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 23
0
        public HttpResponseMessage saveTask(DTOtask request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var dt           = db.task.Where(t => t.taskid == request.taskid).FirstOrDefault();
                var errormessage = new DTOResponseError();
                dt.description            = request.description;
                dt.taskname               = request.taskname;
                dt.performancescore       = request.performancescore;
                dt.tasktype               = request.tasktypes.TaskTypeId;
                dt.attachableobjecttype   = request.objecttypes.typeid;
                dt.attachablepersoneltype = request.personeltypes.typeid;
                dt.updatedby              = user.userId;
                dt.lastupdated            = DateTime.Now;
                db.SaveChanges();
                errormessage.errorCode    = 1;
                errormessage.errorMessage = "İşlem Başarılı";
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 24
0
        public HttpResponseMessage insertSL(DTOSL request)
        { // SL hesaplamaları için gerekli olan bilgilerin kaydı (Hüseyin KOZ)
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
                using (var tran = db.Database.BeginTransaction())
                    try
                    {
                        var errormessage = new DTOResponseError {
                            errorCode = 1, errorMessage = "İşlem Başarılı"
                        };
                        var p = new SL
                        {
                            SLName      = request.SLName,
                            KocSTask    = request.KocSTask,
                            KocETask    = request.KocETask,
                            KocMaxTime  = request.KocMaxTime,
                            BayiSTask   = request.BayiSTask,
                            BayiETask   = request.BayiETask,
                            BayiMaxTime = request.BayiMaxTime,
                            lastupdated = DateTime.Now,
                            updatedby   = user.userId,
                            deleted     = false,
                        };
                        db.SL.Add(p);
                        db.SaveChanges();
                        tran.Commit();
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
                    catch (Exception)
                    {
                        tran.Rollback();
                        var errormessage = new DTOResponseError {
                            errorCode = 2, errorMessage = "Hata Oluştu"
                        };
                        return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
                    }
        }
        public HttpResponseMessage insertTaskState(DTOtaskstatepool request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var tsp = new taskstatepool
                {
                    taskstate    = request.taskstate,
                    statetype    = request.statetype,
                    creationdate = DateTime.Now,
                    lastupdated  = DateTime.Now,
                    updatedby    = user.userId,
                    deleted      = false
                };
                db.taskstatepool.Add(tsp);
                db.SaveChanges();
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
        public HttpResponseMessage insertDocument(DTOdocument request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var d = new document
                {
                    documentname        = request.documentname,
                    documentdescription = request.documentdescription,
                    creationdate        = DateTime.Now,
                    lastupdated         = DateTime.Now,
                    deleted             = false,
                    updatedby           = user.userId
                };
                db.document.Add(d);
                db.SaveChanges();
                DTOResponseError errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 27
0
        public HttpResponseMessage editBlock(DTOblock request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var dblock       = db.block.Where(r => r.blockid == request.blockid).FirstOrDefault();
                var errormessage = new DTOResponseError();

                dblock.blockname       = request.blockname;
                dblock.binakodu        = request.binakodu;
                dblock.cocierge        = request.cocierge;
                dblock.cociergecontact = request.cociergecontact;
                dblock.groupid         = request.groupid;
                dblock.hp              = request.hp;
                dblock.kocsaledate     = request.kocsaledate;
                dblock.locationid      = request.locationid;
                dblock.objid           = request.objid;
                dblock.projectno       = request.projectno;
                dblock.readytosaledate = request.readytosaledate;
                // dblock.salesrepresentative = request.salespersonel.personelid;
                // dblock.siteid = request.site.siteid;
                dblock.sosaledate             = request.sosaledate;
                dblock.superintendent         = request.superintendent;
                dblock.superintendentcontact  = request.superintendentcontact;
                dblock.telocadia              = request.telocadia;
                dblock.updatedby              = user.userId;
                dblock.lastupdated            = DateTime.Now;
                dblock.verticalproductionline = request.verticalproductionline;
                db.SaveChanges();
                errormessage.errorMessage = "İşlem Başarılı";
                errormessage.errorCode    = 1;

                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 28
0
        public HttpResponseMessage savePersonel(DTOpersonel request)
        {
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new CRMEntities())
            {
                var errormessage = new DTOResponseError {
                    errorCode = 1, errorMessage = "İşlem Başarılı"
                };
                var dp = db.personel.Where(t => t.personelid == request.personelid).FirstOrDefault();

                dp.personelname = request.personelname;
                dp.category     = (int)request.category;
                dp.roles        = (int)request.category;
                dp.mobile       = request.mobile;
                dp.email        = request.email;
                dp.password     = request.password;
                dp.notes        = request.notes;
                dp.lastupdated  = DateTime.Now;
                dp.updatedby    = user.userId;
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
            }
        }
Ejemplo n.º 29
0
 public HttpResponseMessage insertProduct(DTOProduct_service request)
 {
     using (var db = new CRMEntities())
     {
         var user         = KOCAuthorizeAttribute.getCurrentUser();
         var errormessage = new DTOResponseError {
             errorCode = 1, errorMessage = "İşlem Başarılı"
         };
         var p = new product_service
         {
             productname        = request.productname,
             category           = request.category,
             automandatorytasks = request.automandatorytasks,
             maxduration        = request.maxduration,
             creationdate       = DateTime.Now,
             lastupdated        = DateTime.Now,
             deleted            = false,
             updatedby          = user.userId
         };
         db.product_service.Add(p);
         db.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.OK, errormessage, "application/json"));
     }
 }
Ejemplo n.º 30
0
        public HttpResponseMessage getStock(DTOGetStockMovementRequest request)
        { // getStockMovements --> fromobject (id) ve toobject (id) olarak geldiğinde isim kontrolü ile çakışma olduğu için oluşturuldu
            var user = KOCAuthorizeAttribute.getCurrentUser();

            using (var db = new KOCSAMADLSEntities())
            {
                if (request.fromobject != null && request.fromobject.value == null && request.toobject.value == null)
                {
                    request.fromobject.value = "";
                }
                var filter   = request.getFilter();
                var querySql = filter.getPagingSQL(request.pageNo, request.rowsPerPage);
                var countSql = filter.getCountSQL();

                var performance = new DTOQueryPerformance();
                var perf        = Stopwatch.StartNew();
                var rowCount    = db.Database.SqlQuery <int>(countSql).First();
                performance.CountSQLDuration = perf.Elapsed;
                perf.Restart();
                var res = db.stockmovement.SqlQuery(querySql).ToList();
                performance.QuerSQLyDuration = perf.Elapsed;
                perf.Restart();
                var fromObjectIds = res.Select(s => s.fromobject).Distinct().ToList();
                var fromPersonels = db.personel.Where(p => fromObjectIds.Contains(p.personelid)).ToList();
                var fromCustomers = db.customer.Where(c => fromObjectIds.Contains(c.customerid)).ToList();


                var toObjectIds = res.Select(s => s.toobject).Distinct().ToList();
                var toPersonels = db.personel.Where(p => toObjectIds.Contains(p.personelid)).ToList();
                var toCustomers = db.customer.Where(c => toObjectIds.Contains(c.customerid)).ToList();


                var stockcardids = res.Select(s => s.stockcardid).Distinct().ToList();
                var stockcards   = db.stockcard.Where(s => stockcardids.Contains(s.stockid)).ToList();

                res.ForEach(r =>
                {
                    r.frompersonel = fromPersonels.Where(p => p.personelid == r.fromobject).FirstOrDefault();
                    if (r.frompersonel == null)
                    {
                        r.fromcustomer = fromCustomers.Where(c => c.customerid == r.fromobject).FirstOrDefault();
                    }
                    r.topersonel = toPersonels.Where(p => p.personelid == r.toobject).FirstOrDefault();
                    if (r.topersonel == null)
                    {
                        r.tocustomer = toCustomers.Where(c => c.customerid == r.toobject).FirstOrDefault();
                    }
                    r.stockcard = stockcards.Where(s => s.stockid == r.stockcardid).FirstOrDefault();
                });
                performance.LookupDuration = perf.Elapsed;
                DTOResponsePagingInfo paginginfo = new DTOResponsePagingInfo
                {
                    pageCount     = (int)Math.Ceiling(rowCount * 1.0 / request.rowsPerPage),
                    pageNo        = request.pageNo,
                    rowsPerPage   = request.rowsPerPage,
                    totalRowCount = rowCount
                };
                return(Request.CreateResponse(HttpStatusCode.OK,
                                              new DTOPagedResponse(DTOResponseError.NoError(), res.Where(r => r.deleted == false).Select(s => s.toDTO()).ToList(), paginginfo, querySql, performance)
                                              , "application/json"));
            }
        }